You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.6 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-Element'>/**
  19. </span> * @class Ext.Element
  20. */
  21. Ext.Element.addMethods({
  22. <span id='Ext-Element-method-isScrollable'> /**
  23. </span> * Returns true if this element is scrollable.
  24. * @return {Boolean}
  25. */
  26. isScrollable : function(){
  27. var dom = this.dom;
  28. return dom.scrollHeight &gt; dom.clientHeight || dom.scrollWidth &gt; dom.clientWidth;
  29. },
  30. <span id='Ext-Element-method-scrollTo'> /**
  31. </span> * Scrolls this element the specified scroll point. It does NOT do bounds checking so if you scroll to a weird value it will try to do it. For auto bounds checking, use scroll().
  32. * @param {String} side Either &quot;left&quot; for scrollLeft values or &quot;top&quot; for scrollTop values.
  33. * @param {Number} value The new scroll value.
  34. * @return {Element} this
  35. */
  36. scrollTo : function(side, value){
  37. this.dom[&quot;scroll&quot; + (/top/i.test(side) ? &quot;Top&quot; : &quot;Left&quot;)] = value;
  38. return this;
  39. },
  40. <span id='Ext-Element-method-getScroll'> /**
  41. </span> * Returns the current scroll position of the element.
  42. * @return {Object} An object containing the scroll position in the format {left: (scrollLeft), top: (scrollTop)}
  43. */
  44. getScroll : function(){
  45. var d = this.dom,
  46. doc = document,
  47. body = doc.body,
  48. docElement = doc.documentElement,
  49. l,
  50. t,
  51. ret;
  52. if(d == doc || d == body){
  53. if(Ext.isIE &amp;&amp; Ext.isStrict){
  54. l = docElement.scrollLeft;
  55. t = docElement.scrollTop;
  56. }else{
  57. l = window.pageXOffset;
  58. t = window.pageYOffset;
  59. }
  60. ret = {left: l || (body ? body.scrollLeft : 0), top: t || (body ? body.scrollTop : 0)};
  61. }else{
  62. ret = {left: d.scrollLeft, top: d.scrollTop};
  63. }
  64. return ret;
  65. }
  66. });</pre>
  67. </body>
  68. </html>