vue-scrollto
Advanced tools
Comparing version 2.6.2 to 2.6.3
{ | ||
"name": "vue-scrollto", | ||
"version": "2.6.2", | ||
"version": "2.6.3", | ||
"description": "Adds a directive that listens for click events and scrolls to elements.", | ||
@@ -5,0 +5,0 @@ "main": "vue-scrollto.js", |
@@ -14,3 +14,3 @@ # vue-scrollto | ||
For `vue 1.x` use `v...` but keep in mind that the old version depends on `jquery`. | ||
For `vue 1.x` use `vue-scrollTo@1.0.1` (note the capital T) but keep in mind that the old version depends on `jquery`. | ||
@@ -48,3 +48,3 @@ ## Under the hood | ||
<script src="https://unpkg.com/vue@2.2.4"></script> | ||
<script src="https://unpkg.com/vue-scrollto@2.6.0"></script> | ||
<script src="https://unpkg.com/vue-scrollto"></script> | ||
``` | ||
@@ -51,0 +51,0 @@ <p class="tip"> |
import scrollTo from "./scrollTo"; | ||
import _ from "./utils"; | ||
const bindings = {}; // store binding data | ||
function handleClick(e) { | ||
e.preventDefault(); | ||
let ctx = bindings[this]; | ||
if (typeof this.value === "string") { | ||
return scrollTo(this.value); | ||
if (typeof ctx.value === "string") { | ||
return scrollTo(ctx.value); | ||
} | ||
scrollTo(this.value.el || this.value.element, this.value); | ||
scrollTo(ctx.value.el || ctx.value.element, ctx.value); | ||
} | ||
@@ -15,8 +18,13 @@ | ||
bind(el, binding) { | ||
_.on(el, "click", handleClick.bind(binding)); | ||
bindings[el] = binding; | ||
_.on(el, "click", handleClick); | ||
}, | ||
unbind(el) { | ||
delete bindings[el]; | ||
_.off(el, "click", handleClick); | ||
}, | ||
update(el, binding) { | ||
bindings[el] = binding; | ||
}, | ||
scrollTo | ||
}; |
@@ -280,9 +280,12 @@ (function (global, factory) { | ||
var bindings = {}; // store binding data | ||
function handleClick(e) { | ||
e.preventDefault(); | ||
var ctx = bindings[this]; | ||
if (typeof this.value === "string") { | ||
return _scroller(this.value); | ||
if (typeof ctx.value === "string") { | ||
return _scroller(ctx.value); | ||
} | ||
_scroller(this.value.el || this.value.element, this.value); | ||
_scroller(ctx.value.el || ctx.value.element, ctx.value); | ||
} | ||
@@ -292,7 +295,12 @@ | ||
bind: function bind(el, binding) { | ||
_.on(el, "click", handleClick.bind(binding)); | ||
bindings[el] = binding; | ||
_.on(el, "click", handleClick); | ||
}, | ||
unbind: function unbind(el) { | ||
delete bindings[el]; | ||
_.off(el, "click", handleClick); | ||
}, | ||
update: function update(el, binding) { | ||
bindings[el] = binding; | ||
}, | ||
@@ -299,0 +307,0 @@ scrollTo: _scroller |
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
22569
452