Sha256: b540bbc9abb8d6013b5809e9be4bba73eda1961f734e9977f80417bcfd6b5a23

Contents?: true

Size: 2 KB

Versions: 44

Compression:

Stored size: 2 KB

Contents

var PageSliderMixin = {

    getInitialState: function () {
        return {
            history: [],
            pages: [],
            animating: false
        }
    },
    componentDidUpdate: function() {
        var skippedCurrentFrame = false,
            pageEl = this.getDOMNode().lastChild,
            pages = this.state.pages,
            l = pages.length,
            transitionEndHandler = function() {
                pageEl.removeEventListener('webkitTransitionEnd', transitionEndHandler);
                pages.shift();
                this.setState({pages: pages});
            }.bind(this),
            animate = function() {
                if (!skippedCurrentFrame) {
                    skippedCurrentFrame = true;
                    requestAnimationFrame(animate.bind(this));
                } else if (l > 0) {
                    pages[l - 1].props.position = "center transition";
                    this.setState({pages: pages, animating: false});
                    pageEl.addEventListener('webkitTransitionEnd', transitionEndHandler);
                }
            };

        if (this.state.animating) {
            requestAnimationFrame(animate.bind(this));
        }
    },
    slidePage: function (page) {
        var history = this.state.history,
            pages = this.state.pages,
            l = history.length,
            hash = window.location.hash,
            position = "center";

        if (l === 0) {
            history.push(hash);
        } else if (hash === history[l - 2]) {
            history.pop();
            position = "left";
        } else {
            history.push(hash);
            position = "right";
        }

        page.props.position = position;
        pages.push(page);

        this.setState({history: history, pages: pages, animating: position!=="center"});

    },
    render: function () {
        return (
            <div className="pageslider-container">
                {this.state.pages}
            </div>
        );
    }
};

module.exports = PageSliderMixin;

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
nutella_framework-0.7.3 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.7.2 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.7.1 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.7.0 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.21 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.20 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.19 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.18 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.17 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.16 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.15 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.13 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.12 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.11 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.10 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.9 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.8 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.7 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.6 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js
nutella_framework-0.6.5 framework_components/roomcast-channel-creator/src/app/components/PageSliderMixin.js