From e2b6d3f02f56c8da2f35d5c8aa2842dd32b8f326 Mon Sep 17 00:00:00 2001 From: Devan Flaherty Date: Fri, 13 Oct 2017 12:27:18 -0600 Subject: [PATCH] Added Instance Method and Value Bindings --- dist/vue-scroll-reveal.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/dist/vue-scroll-reveal.js b/dist/vue-scroll-reveal.js index a713797..f09f10f 100644 --- a/dist/vue-scroll-reveal.js +++ b/dist/vue-scroll-reveal.js @@ -7,6 +7,10 @@ var sr = require('scrollreveal')(); var VueScrollReveal = { install: function install(Vue) { + // Add an instance method so we can fire from function + Vue.prototype.$reveal = function (el, options, int) { + return sr.reveal(el, options, int) + } Vue.directive('scroll-reveal', { inserted: function inserted(el, binding) { var options = binding.value || {}; @@ -21,6 +25,34 @@ var VueScrollReveal = { } } + // Added values so we can set some Scroll Reveal options via the directive + if (binding.value) { + // Where should the component originate from + if (binding.value.origin) { + options.origin = binding.value.origin + } + + // How far should it travel + if (binding.value.distance) { + options.distance = binding.value.distance + } + + // What should the duration be + if (binding.value.duration) { + options.duration = binding.value.duration + } + + // Starting opacity + if (binding.value.opacity) { + options.opacity = binding.value.opacity + } + + // Starting scale + if (binding.value.scale) { + options.scale = binding.value.scale + } + } + sr.reveal(el, options); } });