pull-update
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -281,3 +281,3 @@ var _shared = { | ||
var _ptrStyles = "\n.__PREFIX__ptr {\n pointer-events: none;\n font-size: 0.85em;\n font-weight: bold;\n top: 0;\n height: 0;\n transition: height 0.3s, min-height 0.3s;\n text-align: center;\n width: 100%;\n overflow: hidden;\n display: flex;\n align-items: flex-end;\n align-content: stretch;\n}\n\n.__PREFIX__box {\n flex-basis: 100%;\n}\n\n.__PREFIX__pull {\n transition: none;\n}\n\n.__PREFIX__text {\n margin-top: -2em;\n color: rgba(0, 0, 0, 0.3);\n}\n\n/*\nWhen at the top of the page, disable vertical overscroll so passive touch\nlisteners can take over.\n*/\n.__PREFIX__top {\n touch-action: pan-x pan-down pinch-zoom;\n}\n"; | ||
var _ptrStyles = "\n.__PREFIX__ptr {\n pointer-events: none;\n font-size: 0.85em;\n font-weight: bold;\n top: 0;\n height: 0;\n transition: height 0.3s, min-height 0.3s;\n text-align: center;\n width: 100%;\n overflow: hidden;\n display: flex;\n align-items: flex-end;\n align-content: stretch;\n}\n\n.__PREFIX__box {\n flex-basis: 100%;\n}\n\n.__PREFIX__pull {\n transition: none;\n}\n\n.__PREFIX__text {\n margin-top: -1.6em;\n color: rgba(0, 0, 0, 0.3);\n}\n\n/*\nWhen at the top of the page, disable vertical overscroll so passive touch\nlisteners can take over.\n*/\n.__PREFIX__top {\n touch-action: pan-x pan-down pinch-zoom;\n}\n"; | ||
@@ -284,0 +284,0 @@ var _defaults = { |
@@ -283,3 +283,3 @@ 'use strict'; | ||
var _ptrStyles = "\n.__PREFIX__ptr {\n pointer-events: none;\n font-size: 0.85em;\n font-weight: bold;\n top: 0;\n height: 0;\n transition: height 0.3s, min-height 0.3s;\n text-align: center;\n width: 100%;\n overflow: hidden;\n display: flex;\n align-items: flex-end;\n align-content: stretch;\n}\n\n.__PREFIX__box {\n flex-basis: 100%;\n}\n\n.__PREFIX__pull {\n transition: none;\n}\n\n.__PREFIX__text {\n margin-top: -2em;\n color: rgba(0, 0, 0, 0.3);\n}\n\n/*\nWhen at the top of the page, disable vertical overscroll so passive touch\nlisteners can take over.\n*/\n.__PREFIX__top {\n touch-action: pan-x pan-down pinch-zoom;\n}\n"; | ||
var _ptrStyles = "\n.__PREFIX__ptr {\n pointer-events: none;\n font-size: 0.85em;\n font-weight: bold;\n top: 0;\n height: 0;\n transition: height 0.3s, min-height 0.3s;\n text-align: center;\n width: 100%;\n overflow: hidden;\n display: flex;\n align-items: flex-end;\n align-content: stretch;\n}\n\n.__PREFIX__box {\n flex-basis: 100%;\n}\n\n.__PREFIX__pull {\n transition: none;\n}\n\n.__PREFIX__text {\n margin-top: -1.6em;\n color: rgba(0, 0, 0, 0.3);\n}\n\n/*\nWhen at the top of the page, disable vertical overscroll so passive touch\nlisteners can take over.\n*/\n.__PREFIX__top {\n touch-action: pan-x pan-down pinch-zoom;\n}\n"; | ||
@@ -286,0 +286,0 @@ var _defaults = { |
/*! | ||
* pull-update v0.6.0 | ||
* pull-update v0.7.0 | ||
* (c) Rafael Soto | ||
@@ -292,3 +292,3 @@ * Released under the MIT License. | ||
var _ptrStyles = "\n.__PREFIX__ptr {\n pointer-events: none;\n font-size: 0.85em;\n font-weight: bold;\n top: 0;\n height: 0;\n transition: height 0.3s, min-height 0.3s;\n text-align: center;\n width: 100%;\n overflow: hidden;\n display: flex;\n align-items: flex-end;\n align-content: stretch;\n}\n\n.__PREFIX__box {\n flex-basis: 100%;\n}\n\n.__PREFIX__pull {\n transition: none;\n}\n\n.__PREFIX__text {\n margin-top: -2em;\n color: rgba(0, 0, 0, 0.3);\n}\n\n/*\nWhen at the top of the page, disable vertical overscroll so passive touch\nlisteners can take over.\n*/\n.__PREFIX__top {\n touch-action: pan-x pan-down pinch-zoom;\n}\n"; | ||
var _ptrStyles = "\n.__PREFIX__ptr {\n pointer-events: none;\n font-size: 0.85em;\n font-weight: bold;\n top: 0;\n height: 0;\n transition: height 0.3s, min-height 0.3s;\n text-align: center;\n width: 100%;\n overflow: hidden;\n display: flex;\n align-items: flex-end;\n align-content: stretch;\n}\n\n.__PREFIX__box {\n flex-basis: 100%;\n}\n\n.__PREFIX__pull {\n transition: none;\n}\n\n.__PREFIX__text {\n margin-top: -1.6em;\n color: rgba(0, 0, 0, 0.3);\n}\n\n/*\nWhen at the top of the page, disable vertical overscroll so passive touch\nlisteners can take over.\n*/\n.__PREFIX__top {\n touch-action: pan-x pan-down pinch-zoom;\n}\n"; | ||
@@ -295,0 +295,0 @@ var _defaults = { |
/*! | ||
* pull-update v0.6.0 | ||
* pull-update v0.7.0 | ||
* (c) Rafael Soto | ||
@@ -7,7 +7,7 @@ * Released under the MIT License. | ||
/*! | ||
* pull-update v0.6.0 | ||
* pull-update v0.7.0 | ||
* (c) Rafael Soto | ||
* Released under the MIT License. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).PullToRefresh=t()}(this,(function(){"use strict";var e={pullStartY:null,pullMoveY:null,handlers:[],styleEl:null,events:null,dist:0,state:"pending",timeout:null,distResisted:0,supportsPassive:!1,supportsPointerEvents:"undefined"!=typeof window&&!!window.PointerEvent};try{window.addEventListener("test",null,{get passive(){e.supportsPassive=!0}})}catch(e){}var t,n={setupDOM:function(t){if(!t.ptrElement){var n=document.createElement("div");t.mainElement!==document.body?t.mainElement.parentNode.insertBefore(n,t.mainElement):document.body.insertBefore(n,document.body.firstChild),n.classList.add(t.classPrefix+"ptr"),n.innerHTML=t.getMarkup().replace(/__PREFIX__/g,t.classPrefix),t.ptrElement=n,"function"==typeof t.onInit&&t.onInit(t),e.styleEl||(e.styleEl=document.createElement("style"),e.styleEl.setAttribute("id","pull-to-refresh-js-style"),document.head.appendChild(e.styleEl)),e.styleEl.textContent=t.getStyles().replace(/__PREFIX__/g,t.classPrefix).replace(/\s+/g," ")}return t},onReset:function(t){t.ptrElement&&(t.ptrElement.classList.remove(t.classPrefix+"refresh"),t.ptrElement.style[t.cssProp]="0px",setTimeout((function(){t.ptrElement&&t.ptrElement.parentNode&&(t.ptrElement.parentNode.removeChild(t.ptrElement),t.ptrElement=null),e.state="pending"}),t.refreshTimeout))},update:function(t){var n=t.ptrElement.querySelector("."+t.classPrefix+"icon");n&&"refreshing"===e.state&&(n.innerHTML="<div><svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='margin: auto; background: transparent; display: block; shape-rendering: auto;' width='50px' height='50px' viewBox='0 0 100 100' preserveAspectRatio='xMidYMid'><g transform='rotate(0 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'>repeatCount='indefinite'></animate></rect></g><g transform='rotate(30 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.8333333333333334s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(60 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.75s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(90 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.6666666666666666s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(120 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.5833333333333334s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(150 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.5s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(180 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.4166666666666667s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(210 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.3333333333333333s' repeatCount='indefinite'></animate>/rect></g><g transform='rotate(240 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.25s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(270 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.16666666666666666s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(300 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.08333333333333333s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(330 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='0s' repeatCount='indefinite'></animate></rect></g></svg></div>")}},i=function(t){return e.pointerEventsEnabled&&e.supportsPointerEvents?t.screenY:t.touches[0].screenY},r=function(){var r;function s(t){var s=e.handlers.filter((function(e){return e.contains(t.target)}))[0];e.enable=!!s,s&&"pending"===e.state&&(r=n.setupDOM(s),s.shouldPullToRefresh()&&(e.pullStartY=i(t)),clearTimeout(e.timeout),n.update(s))}function o(t){r&&r.ptrElement&&e.enable&&(e.pullStartY?e.pullMoveY=i(t):r.shouldPullToRefresh()&&(e.pullStartY=i(t)),"refreshing"!==e.state?("pending"===e.state&&(r.ptrElement.classList.add(r.classPrefix+"pull"),e.state="pulling",n.update(r)),e.pullStartY&&e.pullMoveY&&(e.dist=e.pullMoveY-e.pullStartY),e.distExtra=e.dist-r.distIgnore,e.distExtra>0&&(t.cancelable&&t.preventDefault(),r.ptrElement.style[r.cssProp]=e.distResisted+"px",e.distResisted=r.resistanceFunction(e.distExtra/r.distThreshold)*Math.min(r.distMax,e.distExtra),"pulling"===e.state&&e.distResisted>r.distThreshold&&(r.ptrElement.classList.add(r.classPrefix+"release"),e.state="releasing",n.update(r)),"releasing"===e.state&&e.distResisted<r.distThreshold&&(r.ptrElement.classList.remove(r.classPrefix+"release"),e.state="pulling",n.update(r)))):t.cancelable&&r.shouldPullToRefresh()&&e.pullStartY<e.pullMoveY&&t.preventDefault())}function a(){if(r&&r.ptrElement&&e.enable){if(clearTimeout(t),t=setTimeout((function(){r&&r.ptrElement&&"pending"===e.state&&n.onReset(r)}),500),"releasing"===e.state&&e.distResisted>r.distThreshold)e.state="refreshing",r.ptrElement.style[r.cssProp]=r.distReload+"px",r.ptrElement.classList.add(r.classPrefix+"refresh"),e.timeout=setTimeout((function(){var e=r.onRefresh((function(){return n.onReset(r)}));e&&"function"==typeof e.then&&e.then((function(){return n.onReset(r)})),e||r.onRefresh.length||n.onReset(r)}),r.refreshTimeout);else{if("refreshing"===e.state)return;r.ptrElement.style[r.cssProp]="0px",e.state="pending"}n.update(r),r.ptrElement.classList.remove(r.classPrefix+"release"),r.ptrElement.classList.remove(r.classPrefix+"pull"),e.pullStartY=e.pullMoveY=null,e.dist=e.distResisted=0}}function l(){r&&r.mainElement.classList.toggle(r.classPrefix+"top",r.shouldPullToRefresh())}var u=e.supportsPassive?{passive:e.passive||!1}:void 0;return e.pointerEventsEnabled&&e.supportsPointerEvents?(window.addEventListener("pointerup",a),window.addEventListener("pointerdown",s),window.addEventListener("pointermove",o,u)):(window.addEventListener("touchend",a),window.addEventListener("touchstart",s),window.addEventListener("touchmove",o,u)),window.addEventListener("scroll",l),{onTouchEnd:a,onTouchStart:s,onTouchMove:o,onScroll:l,destroy:function(){e.pointerEventsEnabled&&e.supportsPointerEvents?(window.removeEventListener("pointerdown",s),window.removeEventListener("pointerup",a),window.removeEventListener("pointermove",o,u)):(window.removeEventListener("touchstart",s),window.removeEventListener("touchend",a),window.removeEventListener("touchmove",o,u)),window.removeEventListener("scroll",l)}}},s={distThreshold:60,distMax:80,distReload:50,distIgnore:0,mainElement:"body",triggerElement:"body",ptrElement:".ptr",classPrefix:"ptr--",cssProp:"min-height",iconArrow:"⇣",iconRefreshing:"…",instructionsPullToRefresh:"Pull down to refresh",instructionsReleaseToRefresh:"Release to refresh",instructionsRefreshing:"Refreshing",refreshTimeout:500,getMarkup:function(){return'\n<div class="__PREFIX__box">\n <div class="__PREFIX__content">\n <div class="__PREFIX__icon"></div>\n <div class="__PREFIX__text"></div>\n </div>\n</div>\n'},getStyles:function(){return"\n.__PREFIX__ptr {\n pointer-events: none;\n font-size: 0.85em;\n font-weight: bold;\n top: 0;\n height: 0;\n transition: height 0.3s, min-height 0.3s;\n text-align: center;\n width: 100%;\n overflow: hidden;\n display: flex;\n align-items: flex-end;\n align-content: stretch;\n}\n\n.__PREFIX__box {\n flex-basis: 100%;\n}\n\n.__PREFIX__pull {\n transition: none;\n}\n\n.__PREFIX__text {\n margin-top: -2em;\n color: rgba(0, 0, 0, 0.3);\n}\n\n/*\nWhen at the top of the page, disable vertical overscroll so passive touch\nlisteners can take over.\n*/\n.__PREFIX__top {\n touch-action: pan-x pan-down pinch-zoom;\n}\n"},onInit:function(){},onRefresh:function(){return location.reload()},resistanceFunction:function(e){return Math.min(1,e/2.5)},shouldPullToRefresh:function(){return!window.scrollY}},o=["mainElement","ptrElement","triggerElement"],a=function(t){var n={};return Object.keys(s).forEach((function(e){n[e]=t[e]||s[e]})),n.refreshTimeout="number"==typeof t.refreshTimeout?t.refreshTimeout:s.refreshTimeout,o.forEach((function(e){"string"==typeof n[e]&&(n[e]=document.querySelector(n[e]))})),e.events||(e.events=r()),n.contains=function(e){return n.triggerElement.contains(e)},n.destroy=function(){clearTimeout(e.timeout);var t=e.handlers.indexOf(n);e.handlers.splice(t,1)},n};return{setPassiveMode:function(t){e.passive=t},setPointerEventsMode:function(t){e.pointerEventsEnabled=t},destroyAll:function(){e.events&&(e.events.destroy(),e.events=null),e.handlers.forEach((function(e){e.destroy()}))},init:function(t){void 0===t&&(t={});var n=a(t);return e.handlers.push(n),n},_:{setupHandler:a,setupEvents:r,setupDOM:n.setupDOM,onReset:n.onReset,update:n.update}}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).PullToRefresh=t()}(this,(function(){"use strict";var e={pullStartY:null,pullMoveY:null,handlers:[],styleEl:null,events:null,dist:0,state:"pending",timeout:null,distResisted:0,supportsPassive:!1,supportsPointerEvents:"undefined"!=typeof window&&!!window.PointerEvent};try{window.addEventListener("test",null,{get passive(){e.supportsPassive=!0}})}catch(e){}var t,n={setupDOM:function(t){if(!t.ptrElement){var n=document.createElement("div");t.mainElement!==document.body?t.mainElement.parentNode.insertBefore(n,t.mainElement):document.body.insertBefore(n,document.body.firstChild),n.classList.add(t.classPrefix+"ptr"),n.innerHTML=t.getMarkup().replace(/__PREFIX__/g,t.classPrefix),t.ptrElement=n,"function"==typeof t.onInit&&t.onInit(t),e.styleEl||(e.styleEl=document.createElement("style"),e.styleEl.setAttribute("id","pull-to-refresh-js-style"),document.head.appendChild(e.styleEl)),e.styleEl.textContent=t.getStyles().replace(/__PREFIX__/g,t.classPrefix).replace(/\s+/g," ")}return t},onReset:function(t){t.ptrElement&&(t.ptrElement.classList.remove(t.classPrefix+"refresh"),t.ptrElement.style[t.cssProp]="0px",setTimeout((function(){t.ptrElement&&t.ptrElement.parentNode&&(t.ptrElement.parentNode.removeChild(t.ptrElement),t.ptrElement=null),e.state="pending"}),t.refreshTimeout))},update:function(t){var n=t.ptrElement.querySelector("."+t.classPrefix+"icon");n&&"refreshing"===e.state&&(n.innerHTML="<div><svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' style='margin: auto; background: transparent; display: block; shape-rendering: auto;' width='50px' height='50px' viewBox='0 0 100 100' preserveAspectRatio='xMidYMid'><g transform='rotate(0 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'>repeatCount='indefinite'></animate></rect></g><g transform='rotate(30 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.8333333333333334s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(60 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.75s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(90 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.6666666666666666s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(120 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.5833333333333334s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(150 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.5s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(180 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.4166666666666667s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(210 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.3333333333333333s' repeatCount='indefinite'></animate>/rect></g><g transform='rotate(240 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.25s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(270 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.16666666666666666s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(300 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='-0.08333333333333333s' repeatCount='indefinite'></animate></rect></g><g transform='rotate(330 50 50)'><rect x='47.5' y='24' rx='2.5' ry='6' width='5' height='12' fill='#1886f8'><animate attributeName='opacity' values='1;0' keyTimes='0;1' dur='1s' begin='0s' repeatCount='indefinite'></animate></rect></g></svg></div>")}},i=function(t){return e.pointerEventsEnabled&&e.supportsPointerEvents?t.screenY:t.touches[0].screenY},r=function(){var r;function s(t){var s=e.handlers.filter((function(e){return e.contains(t.target)}))[0];e.enable=!!s,s&&"pending"===e.state&&(r=n.setupDOM(s),s.shouldPullToRefresh()&&(e.pullStartY=i(t)),clearTimeout(e.timeout),n.update(s))}function o(t){r&&r.ptrElement&&e.enable&&(e.pullStartY?e.pullMoveY=i(t):r.shouldPullToRefresh()&&(e.pullStartY=i(t)),"refreshing"!==e.state?("pending"===e.state&&(r.ptrElement.classList.add(r.classPrefix+"pull"),e.state="pulling",n.update(r)),e.pullStartY&&e.pullMoveY&&(e.dist=e.pullMoveY-e.pullStartY),e.distExtra=e.dist-r.distIgnore,e.distExtra>0&&(t.cancelable&&t.preventDefault(),r.ptrElement.style[r.cssProp]=e.distResisted+"px",e.distResisted=r.resistanceFunction(e.distExtra/r.distThreshold)*Math.min(r.distMax,e.distExtra),"pulling"===e.state&&e.distResisted>r.distThreshold&&(r.ptrElement.classList.add(r.classPrefix+"release"),e.state="releasing",n.update(r)),"releasing"===e.state&&e.distResisted<r.distThreshold&&(r.ptrElement.classList.remove(r.classPrefix+"release"),e.state="pulling",n.update(r)))):t.cancelable&&r.shouldPullToRefresh()&&e.pullStartY<e.pullMoveY&&t.preventDefault())}function a(){if(r&&r.ptrElement&&e.enable){if(clearTimeout(t),t=setTimeout((function(){r&&r.ptrElement&&"pending"===e.state&&n.onReset(r)}),500),"releasing"===e.state&&e.distResisted>r.distThreshold)e.state="refreshing",r.ptrElement.style[r.cssProp]=r.distReload+"px",r.ptrElement.classList.add(r.classPrefix+"refresh"),e.timeout=setTimeout((function(){var e=r.onRefresh((function(){return n.onReset(r)}));e&&"function"==typeof e.then&&e.then((function(){return n.onReset(r)})),e||r.onRefresh.length||n.onReset(r)}),r.refreshTimeout);else{if("refreshing"===e.state)return;r.ptrElement.style[r.cssProp]="0px",e.state="pending"}n.update(r),r.ptrElement.classList.remove(r.classPrefix+"release"),r.ptrElement.classList.remove(r.classPrefix+"pull"),e.pullStartY=e.pullMoveY=null,e.dist=e.distResisted=0}}function l(){r&&r.mainElement.classList.toggle(r.classPrefix+"top",r.shouldPullToRefresh())}var u=e.supportsPassive?{passive:e.passive||!1}:void 0;return e.pointerEventsEnabled&&e.supportsPointerEvents?(window.addEventListener("pointerup",a),window.addEventListener("pointerdown",s),window.addEventListener("pointermove",o,u)):(window.addEventListener("touchend",a),window.addEventListener("touchstart",s),window.addEventListener("touchmove",o,u)),window.addEventListener("scroll",l),{onTouchEnd:a,onTouchStart:s,onTouchMove:o,onScroll:l,destroy:function(){e.pointerEventsEnabled&&e.supportsPointerEvents?(window.removeEventListener("pointerdown",s),window.removeEventListener("pointerup",a),window.removeEventListener("pointermove",o,u)):(window.removeEventListener("touchstart",s),window.removeEventListener("touchend",a),window.removeEventListener("touchmove",o,u)),window.removeEventListener("scroll",l)}}},s={distThreshold:60,distMax:80,distReload:50,distIgnore:0,mainElement:"body",triggerElement:"body",ptrElement:".ptr",classPrefix:"ptr--",cssProp:"min-height",iconArrow:"⇣",iconRefreshing:"…",instructionsPullToRefresh:"Pull down to refresh",instructionsReleaseToRefresh:"Release to refresh",instructionsRefreshing:"Refreshing",refreshTimeout:500,getMarkup:function(){return'\n<div class="__PREFIX__box">\n <div class="__PREFIX__content">\n <div class="__PREFIX__icon"></div>\n <div class="__PREFIX__text"></div>\n </div>\n</div>\n'},getStyles:function(){return"\n.__PREFIX__ptr {\n pointer-events: none;\n font-size: 0.85em;\n font-weight: bold;\n top: 0;\n height: 0;\n transition: height 0.3s, min-height 0.3s;\n text-align: center;\n width: 100%;\n overflow: hidden;\n display: flex;\n align-items: flex-end;\n align-content: stretch;\n}\n\n.__PREFIX__box {\n flex-basis: 100%;\n}\n\n.__PREFIX__pull {\n transition: none;\n}\n\n.__PREFIX__text {\n margin-top: -1.6em;\n color: rgba(0, 0, 0, 0.3);\n}\n\n/*\nWhen at the top of the page, disable vertical overscroll so passive touch\nlisteners can take over.\n*/\n.__PREFIX__top {\n touch-action: pan-x pan-down pinch-zoom;\n}\n"},onInit:function(){},onRefresh:function(){return location.reload()},resistanceFunction:function(e){return Math.min(1,e/2.5)},shouldPullToRefresh:function(){return!window.scrollY}},o=["mainElement","ptrElement","triggerElement"],a=function(t){var n={};return Object.keys(s).forEach((function(e){n[e]=t[e]||s[e]})),n.refreshTimeout="number"==typeof t.refreshTimeout?t.refreshTimeout:s.refreshTimeout,o.forEach((function(e){"string"==typeof n[e]&&(n[e]=document.querySelector(n[e]))})),e.events||(e.events=r()),n.contains=function(e){return n.triggerElement.contains(e)},n.destroy=function(){clearTimeout(e.timeout);var t=e.handlers.indexOf(n);e.handlers.splice(t,1)},n};return{setPassiveMode:function(t){e.passive=t},setPointerEventsMode:function(t){e.pointerEventsEnabled=t},destroyAll:function(){e.events&&(e.events.destroy(),e.events=null),e.handlers.forEach((function(e){e.destroy()}))},init:function(t){void 0===t&&(t={});var n=a(t);return e.handlers.push(n),n},_:{setupHandler:a,setupEvents:r,setupDOM:n.setupDOM,onReset:n.onReset,update:n.update}}})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "pull-update", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Pull To Refresh", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57033