1function ScrollTo(scrollToElement, clickedElement, callback) { 2 if (!scrollToElement) { 3 throw new Error('Parametr jest wymagany!'); 4 } 5 6 this.scrollToElement = scrollToElement; 7 this.clickedElement = clickedElement ? clickedElement : null; 8 this.callback = callback; 9 this.duration = 1000; 10 this.events(); 11} 12 13ScrollTo.prototype = { 14 constructor: ScrollTo, 15 16 events: function () { 17 const _this = this; 18 19 if (this.clickedElement) { 20 this.clickedElement.on('click', function () { 21 _this.scroll(); 22 }); 23 } 24 }, 25 26 // A function to call once the animation is complete, called once per matched element. 27 animationIsComplete: function () { 28 if (this.callback) { 29 this.callback(); 30 } 31 }, 32 33 getScrollPosition: function () { 34 return $(window).scrollTop(); 35 }, 36 37 scroll: function () { 38 const _this = this; 39 40 $('html, body').animate( 41 { 42 scrollTop: _this.scrollToElement.position().top, 43 }, 44 this.duration, 45 'easeInOutExpo', 46 function () { 47 $(this).clearQueue(); 48 _this.animationIsComplete(); 49 } 50 ); 51 }, 52};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.