Sha256: 3b139ee3be203d0402ddb7f8c30e34b290d70064f6b1b530ef9bbcb4df55402f

Contents?: true

Size: 1.03 KB

Versions: 62

Compression:

Stored size: 1.03 KB

Contents

/**
 * @namespace WORKAREA.scrollToButtons
 */
WORKAREA.registerModule('scrollToButtons', (function () {
    'use strict';

    var scrollToElement = function ($element) {
            $('html, body').animate({
                scrollTop: $element.offset().top - WORKAREA.config.scrollToButtons.topOffset
            }, WORKAREA.config.scrollToButtons.animationSpeed);
        },

        testElement = function (event) {
            var $view = $(event.currentTarget).closest('.view'),
                $targetElement = $view.find(event.currentTarget.hash);

            if (_.isEmpty($targetElement)) { return; }

            event.preventDefault();

            WORKAREA.scrollToButtons.scrollToElement($targetElement);
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.scrollToButtons
         */
        init = function ($scope) {
            $('[data-scroll-to-button]', $scope).on('click', testElement);
        };

    return {
        init: init,
        scrollToElement: scrollToElement
    };
}()));

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-storefront-3.4.13 app/assets/javascripts/workarea/storefront/modules/scroll_to_buttons.js
workarea-storefront-3.4.12 app/assets/javascripts/workarea/storefront/modules/scroll_to_buttons.js