You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

vue-scroll-picker

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-scroll-picker - npm Package Compare versions

Comparing version

to
0.4.1

2

dist/index.js

@@ -1,2 +0,2 @@

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){},function(t,e,n){},function(t,e,n){"use strict";n.r(e);n(0);var i="undefined"!=typeof window&&"ontouchstart"in window,o={props:{value:null,options:{type:Array,default:function(){return[]}},dragSensitivity:{type:Number,default:1.7},touchSensitivity:{type:Number,default:1.7},scrollSensitivity:{type:Number,default:1},empty:{type:String,default:"No Items"},placeholder:{type:String,default:null}},data:function(){var t=this,e=this.normalizeOptions(this.options),n=e[0]&&e[0].value,i=this.placeholder?-1:0,o=this.placeholder?null:void 0===n?null:n;return this.value&&e.forEach((function(e,n){if(e.value==t.value)return i=n,o=e.value,!1})),{normalizedOptions:e,innerIndex:i,innerValue:o,top:0,pivots:null,transitioning:!1,transitionTO:null,startTop:null,isMouseDown:!1,isDragging:!1,isScrolling:!1,startY:null,scrollMax:null}},mounted:function(){i?(this.$el.addEventListener("touchstart",this.onStart),this.$el.addEventListener("touchmove",this.onTouchMove),this.$el.addEventListener("touchend",this.onEnd),this.$el.addEventListener("touchcancel",this.onCancel)):(this.$el.addEventListener("mousewheel",this.onScroll),this.$el.addEventListener("wheel",this.onScroll),this.$el.addEventListener("mousedown",this.onStart),this.$el.addEventListener("mousemove",this.onMouseMove),this.$el.addEventListener("mouseup",this.onEnd),this.$el.addEventListener("mouseleave",this.onCancel)),this.calculatePivots(),this.innerValue!==this.value&&this.$emit("input",this.innerValue)},destroyed:function(){i?(this.$el.removeEventListener("touchstart",this.onStart),this.$el.removeEventListener("touchmove",this.onTouchMove),this.$el.removeEventListener("touchend",this.onEnd),this.$el.removeEventListener("touchcancel",this.onCancel)):(this.$el.removeEventListener("mousewheel",this.onScroll),this.$el.removeEventListener("wheel",this.onScroll),this.$el.removeEventListener("mousedown",this.onStart),this.$el.removeEventListener("mousemove",this.onMouseMove),this.$el.removeEventListener("mouseup",this.onEnd),this.$el.removeEventListener("mouseleave",this.onCancel))},watch:{value:function(t){var e=this.placeholder?-1:0;this.normalizedOptions.forEach((function(n,i){if(n.value==t)return e=i,!1})),this.innerIndex!==e&&this.correction(e)},options:function(t){var e=this;this.normalizedOptions=this.normalizeOptions(t);var n=this.innerIndex>=t.length?t.length-1:0,i=this.normalizedOptions[n]&&this.normalizedOptions[n].value,o=this.placeholder?-1:n,r=this.placeholder?null:void 0===i?null:i;this.normalizedOptions.forEach((function(t,n){if(t.value==e.innerValue)return o=n,r=t.value,!1})),this.$nextTick((function(){e.calculatePivots(),e.innerIndex===o&&e.innerValue===r||(e.top=o>-1?-1*e.pivots[o]:0,e.innerIndex=o,e.innerValue=r,e.$emit("input",e.innerValue))}))}},methods:{normalizeOptions:function(t){return t.map((function(t){return t.hasOwnProperty("value")&&t.hasOwnProperty("name")?t:{value:t,name:t}}))},calculatePivots:function(){var t=this,e=this.$refs.selection.getBoundingClientRect(),n=(e.top+e.bottom)/2;this.pivots=(this.$refs.items||[]).map((function(e){var i=e.getBoundingClientRect(),o=i.top,r=i.bottom;return Math.round(10*((o+r)/2-n))/10-t.top})).sort((function(t,e){return t-e})),this.scrollMax=-1*this.pivots[this.pivots.length-1],this.innerIndex>0&&(this.top=-1*this.pivots[this.innerIndex])},onScroll:function(t){var e=this;this.top>=0&&t.deltaY<0||this.top<=this.scrollMax&&t.deltaY>0||(t.preventDefault(),t.stopPropagation(),this.isScrolling||(this.isScrolling=!0,t.deltaY<0?this.correction(this.innerIndex-Math.floor(Math.abs(t.deltaY)/30*this.scrollSensitivity+1)):t.deltaY>0&&this.correction(this.innerIndex+Math.floor(Math.abs(t.deltaY)/30*this.scrollSensitivity+1)),setTimeout((function(){e.isScrolling=!1}),80)))},getTouchInfo:function(t){return i?t.changedTouches[0]||t.touches[0]:t},onStart:function(t){t.cancelable&&(t.preventDefault(),t.stopPropagation());var e=this.getTouchInfo(t);this.startTop=this.top,this.startY=e.pageY,i||(this.isMouseDown=!0),this.isDragging=!1},onTouchMove:function(t){if(t.preventDefault(),t.stopPropagation(),i||this.isMouseDown){var e=this.getTouchInfo(t).pageY-this.startY;Math.abs(e)>1.5&&(this.isDragging=!0),this.top=this.startTop+e*this.touchSensitivity}},onMouseMove:function(t){if(t.preventDefault(),t.stopPropagation(),i||this.isMouseDown){var e=this.getTouchInfo(t).pageY-this.startY;Math.abs(e)>1.5&&(this.isDragging=!0),this.top=this.startTop+e*this.dragSensitivity}},onEnd:function(t){if(t.preventDefault(),t.stopPropagation(),!this.isDragging)return this.isDragging=!1,this.isMouseDown=!1,void this.handleClick(t);this.isDragging=!1,this.isMouseDown=!1,this.correctionAfterDragging()},onCancel:function(t){t.preventDefault(),t.stopPropagation(),(i||this.isMouseDown)&&(this.correctionAfterDragging(),this.isMouseDown=!1,this.isDragging=!1)},handleClick:function(t){var e=this.getTouchInfo(t),n=e.clientX,i=e.clientY,o=this.$refs.top.getBoundingClientRect(),r=this.$refs.bottom.getBoundingClientRect();o.left<=n&&n<=o.right&&o.top<=i&&i<=o.bottom?this.correction(this.innerIndex-1):r.left<=n&&n<=r.right&&r.top<=i&&i<=r.bottom&&this.correction(this.innerIndex+1)},correctionAfterDragging:function(){var t=null,e=null,n=this.top;this.placeholder&&(t=-1,e=0+n),this.pivots.forEach((function(i,o){var r=i+n;(null===e||Math.abs(e)>Math.abs(r))&&(t=o,e=r)})),this.correction(t)},correction:function(t){var e=this;t=Math.min(Math.max(t,this.placeholder?-1:0),this.pivots.length-1),this.top=t>-1?-1*this.pivots[t]:0,this.transitioning=!0,this.transitionTO&&(clearTimeout(this.transitionTO),this.transitionTO=null),this.innerIndex!==t&&(this.innerIndex=t,this.innerValue=t>-1?this.normalizedOptions[t].value:null,this.$emit("input",this.innerValue)),this.transitionTO=setTimeout((function(){e.transitioning=!1,e.transitionTO=null}),100)}},render:function(t){var e=this,n=[];return 0===this.normalizedOptions.length&&null===this.placeholder&&n.push(t("div",{class:["vue-scroll-picker-item","-empty","-selected"],ref:"empty",domProps:{innerHTML:this.empty}})),this.placeholder&&n.push(t("div",{class:{"vue-scroll-picker-item":!0,"-placeholder":!0,"-selected":-1==this.innerIndex},ref:"placeholder",domProps:{innerHTML:this.placeholder}})),n=n.concat(this.normalizedOptions.map((function(n,i){return t("div",{class:{"vue-scroll-picker-item":!0,"-selected":e.innerIndex==i},key:n.value,ref:"items",refInFor:!0,domProps:{innerHTML:n.name}})}))),t("div",{class:["vue-scroll-picker"]},[t("div",{class:["vue-scroll-picker-list"]},[t("div",{class:{"vue-scroll-picker-list-rotator":!0,"-transition":this.transitioning},style:{top:"".concat(this.top,"px")}},n)]),t("div",{class:["vue-scroll-picker-layer"]},[t("div",{class:["top"],ref:"top"}),t("div",{class:["middle"],ref:"selection"}),t("div",{class:["bottom"],ref:"bottom"})])])}};n(1);function r(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var s={render:function(t){return t("div",{class:["vue-scroll-picker-group"]},r(this.$slots.default))}};function l(t){t.component("ScrollPicker",o),t.component("ScrollPickerGroup",s)}n.d(e,"install",(function(){return l})),n.d(e,"ScrollPicker",(function(){return o})),n.d(e,"ScrollPickerGroup",(function(){return s})),"undefined"!=typeof window&&window.Vue&&l(window.Vue);e.default={install:l}}])}));
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){},function(t,e,n){},function(t,e,n){"use strict";n.r(e);n(0);var i="undefined"!=typeof window&&"ontouchstart"in window,o={props:{value:null,options:{type:Array,default:function(){return[]}},dragSensitivity:{type:Number,default:1.7},touchSensitivity:{type:Number,default:1.7},scrollSensitivity:{type:Number,default:1},empty:{type:String,default:"No Items"},placeholder:{type:String,default:null}},data:function(){var t=this,e=this.normalizeOptions(this.options),n=e[0]&&e[0].value,i=this.placeholder?-1:0,o=this.placeholder?null:void 0===n?null:n;return null!=this.value&&e.forEach((function(e,n){if(e.value==t.value)return i=n,o=e.value,!1})),{normalizedOptions:e,innerIndex:i,innerValue:o,top:0,pivots:null,transitioning:!1,transitionTO:null,startTop:null,isMouseDown:!1,isDragging:!1,isScrolling:!1,startY:null,scrollMax:null}},mounted:function(){i?(this.$el.addEventListener("touchstart",this.onStart),this.$el.addEventListener("touchmove",this.onTouchMove),this.$el.addEventListener("touchend",this.onEnd),this.$el.addEventListener("touchcancel",this.onCancel)):(this.$el.addEventListener("mousewheel",this.onScroll),this.$el.addEventListener("wheel",this.onScroll),this.$el.addEventListener("mousedown",this.onStart),this.$el.addEventListener("mousemove",this.onMouseMove),this.$el.addEventListener("mouseup",this.onEnd),this.$el.addEventListener("mouseleave",this.onCancel)),this.calculatePivots(),this.innerValue!==this.value&&this.$emit("input",this.innerValue)},destroyed:function(){i?(this.$el.removeEventListener("touchstart",this.onStart),this.$el.removeEventListener("touchmove",this.onTouchMove),this.$el.removeEventListener("touchend",this.onEnd),this.$el.removeEventListener("touchcancel",this.onCancel)):(this.$el.removeEventListener("mousewheel",this.onScroll),this.$el.removeEventListener("wheel",this.onScroll),this.$el.removeEventListener("mousedown",this.onStart),this.$el.removeEventListener("mousemove",this.onMouseMove),this.$el.removeEventListener("mouseup",this.onEnd),this.$el.removeEventListener("mouseleave",this.onCancel))},watch:{value:function(t){var e=this.placeholder?-1:0;this.normalizedOptions.forEach((function(n,i){if(n.value==t)return e=i,!1})),this.innerIndex!==e&&this.correction(e)},options:function(t){var e=this;this.normalizedOptions=this.normalizeOptions(t);var n=this.innerIndex>=t.length?t.length-1:0,i=this.normalizedOptions[n]&&this.normalizedOptions[n].value,o=this.placeholder?-1:n,r=this.placeholder?null:void 0===i?null:i;this.normalizedOptions.forEach((function(t,n){if(t.value==e.innerValue)return o=n,r=t.value,!1})),this.$nextTick((function(){e.calculatePivots(),e.innerIndex===o&&e.innerValue===r||(e.top=o>-1?-1*e.pivots[o]:0,e.innerIndex=o,e.innerValue=r,e.$emit("input",e.innerValue))}))}},methods:{normalizeOptions:function(t){return t.map((function(t){return t.hasOwnProperty("value")&&t.hasOwnProperty("name")?t:{value:t,name:t}}))},calculatePivots:function(){var t=this,e=this.$refs.selection.getBoundingClientRect(),n=(e.top+e.bottom)/2;this.pivots=(this.$refs.items||[]).map((function(e){var i=e.getBoundingClientRect(),o=i.top,r=i.bottom;return Math.round(10*((o+r)/2-n))/10-t.top})).sort((function(t,e){return t-e})),this.scrollMax=-1*this.pivots[this.pivots.length-1],this.innerIndex>-1&&(this.top=-1*this.pivots[this.innerIndex])},onScroll:function(t){var e=this;this.top>=0&&t.deltaY<0||this.top<=this.scrollMax&&t.deltaY>0||(t.preventDefault(),t.stopPropagation(),this.isScrolling||(this.isScrolling=!0,t.deltaY<0?this.correction(this.innerIndex-Math.floor(Math.abs(t.deltaY)/30*this.scrollSensitivity+1)):t.deltaY>0&&this.correction(this.innerIndex+Math.floor(Math.abs(t.deltaY)/30*this.scrollSensitivity+1)),setTimeout((function(){e.isScrolling=!1}),80)))},getTouchInfo:function(t){return i?t.changedTouches[0]||t.touches[0]:t},onStart:function(t){t.cancelable&&(t.preventDefault(),t.stopPropagation());var e=this.getTouchInfo(t);this.startTop=this.top,this.startY=e.pageY,i||(this.isMouseDown=!0),this.isDragging=!1},onTouchMove:function(t){if(t.preventDefault(),t.stopPropagation(),i||this.isMouseDown){var e=this.getTouchInfo(t).pageY-this.startY;Math.abs(e)>1.5&&(this.isDragging=!0),this.top=this.startTop+e*this.touchSensitivity}},onMouseMove:function(t){if(t.preventDefault(),t.stopPropagation(),i||this.isMouseDown){var e=this.getTouchInfo(t).pageY-this.startY;Math.abs(e)>1.5&&(this.isDragging=!0),this.top=this.startTop+e*this.dragSensitivity}},onEnd:function(t){if(t.preventDefault(),t.stopPropagation(),!this.isDragging)return this.isDragging=!1,this.isMouseDown=!1,void this.handleClick(t);this.isDragging=!1,this.isMouseDown=!1,this.correctionAfterDragging()},onCancel:function(t){t.preventDefault(),t.stopPropagation(),(i||this.isMouseDown)&&(this.correctionAfterDragging(),this.isMouseDown=!1,this.isDragging=!1)},handleClick:function(t){var e=this.getTouchInfo(t),n=e.clientX,i=e.clientY,o=this.$refs.top.getBoundingClientRect(),r=this.$refs.bottom.getBoundingClientRect();o.left<=n&&n<=o.right&&o.top<=i&&i<=o.bottom?this.correction(this.innerIndex-1):r.left<=n&&n<=r.right&&r.top<=i&&i<=r.bottom&&this.correction(this.innerIndex+1)},correctionAfterDragging:function(){var t=null,e=null,n=this.top;this.placeholder&&(t=-1,e=0+n),this.pivots.forEach((function(i,o){var r=i+n;(null===e||Math.abs(e)>Math.abs(r))&&(t=o,e=r)})),this.correction(t)},correction:function(t){var e=this;t=Math.min(Math.max(t,this.placeholder?-1:0),this.pivots.length-1),this.top=t>-1?-1*this.pivots[t]:0,this.transitioning=!0,this.transitionTO&&(clearTimeout(this.transitionTO),this.transitionTO=null),this.innerIndex!==t&&(this.innerIndex=t,this.innerValue=t>-1?this.normalizedOptions[t].value:null,this.$emit("input",this.innerValue)),this.transitionTO=setTimeout((function(){e.transitioning=!1,e.transitionTO=null}),100)}},render:function(t){var e=this,n=[];return 0===this.normalizedOptions.length&&null===this.placeholder&&n.push(t("div",{class:["vue-scroll-picker-item","-empty","-selected"],ref:"empty",domProps:{innerHTML:this.empty}})),this.placeholder&&n.push(t("div",{class:{"vue-scroll-picker-item":!0,"-placeholder":!0,"-selected":-1==this.innerIndex},ref:"placeholder",domProps:{innerHTML:this.placeholder}})),n=n.concat(this.normalizedOptions.map((function(n,i){return t("div",{class:{"vue-scroll-picker-item":!0,"-selected":e.innerIndex==i},key:n.value,ref:"items",refInFor:!0,domProps:{innerHTML:n.name}})}))),t("div",{class:["vue-scroll-picker"]},[t("div",{class:["vue-scroll-picker-list"]},[t("div",{class:{"vue-scroll-picker-list-rotator":!0,"-transition":this.transitioning},style:{top:"".concat(this.top,"px")}},n)]),t("div",{class:["vue-scroll-picker-layer"]},[t("div",{class:["top"],ref:"top"}),t("div",{class:["middle"],ref:"selection"}),t("div",{class:["bottom"],ref:"bottom"})])])}};n(1);function r(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var s={render:function(t){return t("div",{class:["vue-scroll-picker-group"]},r(this.$slots.default))}};function l(t){t.component("ScrollPicker",o),t.component("ScrollPickerGroup",s)}n.d(e,"install",(function(){return l})),n.d(e,"ScrollPicker",(function(){return o})),n.d(e,"ScrollPickerGroup",(function(){return s})),"undefined"!=typeof window&&window.Vue&&l(window.Vue);e.default={install:l}}])}));
//# sourceMappingURL=index.js.map
{
"name": "vue-scroll-picker",
"version": "0.4.0",
"version": "0.4.1",
"description": "Scroll Picker Component for Vue.js.",

@@ -5,0 +5,0 @@ "author": "Changwan Jun",

@@ -39,3 +39,3 @@ import "./picker.scss"

let innerValue = this.placeholder ? null : (typeof defaultValue === 'undefined' ? null : defaultValue)
if (this.value) {
if (this.value != null) {
normalizedOptions.forEach((option, index) => {

@@ -152,3 +152,3 @@ if (option.value == this.value) {

this.scrollMax = this.pivots[this.pivots.length - 1] * (-1)
if (this.innerIndex > 0) {
if (this.innerIndex > -1) {
this.top = this.pivots[this.innerIndex] * (-1)

@@ -155,0 +155,0 @@ }

Sorry, the diff of this file is not supported yet