Вход Регистрация
Файл: src/javascript/core/index.js
Строк: 102
<?php
module
.exports = function (items) {
    var 
slides = [].slice.call(items),
        
activeSlide slides[-1],
        
listeners = {},

        
getActiveIndex = function () {
            return 
slides.indexOf(activeSlide);
        },

        
createEventData = function (eleventData) {
            
eventData eventData || {};
            
eventData.index slides.indexOf(el);
            
eventData.slide el;
            return 
eventData;
        },

        
fire = function (eventNameeventData) {
            return (
listeners[eventName] || []).reduce(function (notCancelledcallback) {
                return 
notCancelled && callback(eventData) !== false;
            }, 
true);
        },

        
touch = function (customData) {
            return 
fire('activate'createEventData(activeSlidecustomData));
        },

        
activate = function (indexcustomData) {
            if (!
slides[index]) return;

            
fire('deactivate'createEventData(activeSlidecustomData));
            
activeSlide slides[index];

            
touch(customData);
        },

        
slide = function (indexcustomData) {
            var 
activeIndex getActiveIndex();

            
// if already on this slideIndex, do nothing
            
if (activeIndex === index) return;

            if (
arguments.length) {
                
fire('slide'createEventData(slides[index], customData));
                
activate(indexcustomData);
            } else {
                return 
activeIndex;
            }
        },

        
step = function (offsetcustomData) {
            var 
slideIndex slides.indexOf(activeSlide) + offset;

            
fire(offset 'next' 'prev'createEventData(activeSlidecustomData));
            
activate(slideIndexcustomData);
        },

        
on = function (eventNamecallback) {
            (
listeners[eventName] || (listeners[eventName] = [])).push(callback);

            return function () {
                
listeners[eventName] = listeners[eventName].filter(function (listener) {
                    return 
listener !== callback;
                });
            };
        };

    
// return the slider object
    
return {
        
onon,
        
firefire,
        
touchtouch,
        
slideslide,
        
nextstep.bind(null1),
        
prevstep.bind(null, -1),
        
slidesslides
    
};
};
?>
Онлайн: 0
Реклама