1/** 2 * Created by emas on 06.05.2016. 3 */ 4(function ($) { 5 $.fn.isWindowScrolledToElement = function (offset) { 6 offset = parseInt(offset) || 0; 7 return $(document).scrollTop() + $(window).height() > $(this).offset().top + offset; 8 }; 9 10 $.fn.onScrollToElement = function (callbackOnScroll, 11 callbackIfAlreadyScrolled, 12 execTriggerEvenIfAlreadyScrolled, 13 scrollOutCallback, 14 options 15 ) { 16 var t = this; 17 18 if (!t.size()) return; 19 if (!options) options = {}; 20 21 $(document).bind('scroll.scrolltoelements', function () { 22 if ($(t).isWindowScrolledToElement(options.offset)) { 23 if (!$(t).data('scrolled-to-element')) { 24 $(t).data('scrolled-to-element', true); 25 if (typeof callbackOnScroll == 'function') callbackOnScroll.call(t); 26 } 27 } else { 28 if ($(t).data('scrolled-to-element')) { 29 if (typeof scrollOutCallback == 'function') { 30 $(t).data('scrolled-to-element', false); 31 scrollOutCallback.call(t); 32 } 33 } 34 } 35 }); 36 37 if (!$(t).isWindowScrolledToElement(options.offset)) { 38 39 } else { 40 if (execTriggerEvenIfAlreadyScrolled) { 41 if (typeof callbackOnScroll == 'function') { 42 $(t).data('scrolled-to-element', true); 43 callbackOnScroll.call(t); 44 } 45 } 46 47 if (typeof callbackIfAlreadyScrolled == 'function') callbackIfAlreadyScrolled.call(t); 48 } 49 }; 50 51 $.fn.scrollToThis = function() { 52 if (this.offset()) 53 $('html, body').scrollTop(this.offset().top - ($(window).height() / 3)); 54 return this; 55 }; 56 57 window.scrollToTarget = function (target) { 58 59 var targetTopPos, 60 topPanel = $('.sticky-panel'), 61 topPanelHeight = topPanel.height() || 0; 62 63 if(target.length > 0){ 64 targetTopPos = target.offset().top - topPanelHeight; 65 $('html, body').animate({scrollTop: targetTopPos}, 300); 66 } 67 }; 68 69})(jQuery);
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.