vue-scrollto
Advanced tools
Comparing version 2.6.3 to 2.6.4
{ | ||
"name": "vue-scrollto", | ||
"version": "2.6.3", | ||
"version": "2.6.4", | ||
"description": "Adds a directive that listens for click events and scrolls to elements.", | ||
@@ -5,0 +5,0 @@ "main": "vue-scrollto.js", |
import scrollTo from "./scrollTo"; | ||
import _ from "./utils"; | ||
const bindings = {}; // store binding data | ||
let bindings = []; // store binding data | ||
function deleteBinding(el) { | ||
for (let i = 0; i < bindings.length; ++i) { | ||
if (bindings[i].el === el) { | ||
bindings.splice(i, 1); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
function getBinding(el) { | ||
let binding = bindings.find(entry => { | ||
return entry.el == el; | ||
}); | ||
if (binding) { | ||
return binding; | ||
} | ||
bindings.push( | ||
binding = { | ||
el: el, | ||
binding: {} | ||
} | ||
); | ||
return binding; | ||
} | ||
function handleClick(e) { | ||
e.preventDefault(); | ||
let ctx = bindings[this]; | ||
let ctx = getBinding(this).binding; | ||
@@ -18,13 +47,14 @@ if (typeof ctx.value === "string") { | ||
bind(el, binding) { | ||
bindings[el] = binding; | ||
getBinding(el).binding = binding; | ||
_.on(el, "click", handleClick); | ||
}, | ||
unbind(el) { | ||
delete bindings[el]; | ||
deleteBinding(el); | ||
_.off(el, "click", handleClick); | ||
}, | ||
update(el, binding) { | ||
bindings[el] = binding; | ||
getBinding(el).binding = binding; | ||
}, | ||
scrollTo | ||
scrollTo, | ||
bindings | ||
}; |
@@ -280,7 +280,34 @@ (function (global, factory) { | ||
var bindings = {}; // store binding data | ||
var bindings = []; // store binding data | ||
function deleteBinding(el) { | ||
for (var i = 0; i < bindings.length; ++i) { | ||
if (bindings[i].el === el) { | ||
bindings.splice(i, 1); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
function getBinding(el) { | ||
var binding = bindings.find(function (entry) { | ||
return entry.el == el; | ||
}); | ||
if (binding) { | ||
return binding; | ||
} | ||
bindings.push(binding = { | ||
el: el, | ||
binding: {} | ||
}); | ||
return binding; | ||
} | ||
function handleClick(e) { | ||
e.preventDefault(); | ||
var ctx = bindings[this]; | ||
var ctx = getBinding(this).binding; | ||
@@ -295,14 +322,15 @@ if (typeof ctx.value === "string") { | ||
bind: function bind(el, binding) { | ||
bindings[el] = binding; | ||
getBinding(el).binding = binding; | ||
_.on(el, "click", handleClick); | ||
}, | ||
unbind: function unbind(el) { | ||
delete bindings[el]; | ||
deleteBinding(el); | ||
_.off(el, "click", handleClick); | ||
}, | ||
update: function update(el, binding) { | ||
bindings[el] = binding; | ||
getBinding(el).binding = binding; | ||
}, | ||
scrollTo: _scroller | ||
scrollTo: _scroller, | ||
bindings: bindings | ||
}; | ||
@@ -309,0 +337,0 @@ |
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
23631
500