be-fe / iSlider

Smooth mobile touch slider for Mobile WebApp, HTML5 App, Hybrid App
http://be-fe.github.io/iSlider/
MIT License
1.66k stars 448 forks source link

添加方法 #363

Closed marginTop closed 8 years ago

marginTop commented 8 years ago
/**
     * Add scenes to the head of the data datasheets
     *
     * @param {Object|Array} sceneData
     * @description
     *   Object:
     *     {content:...}
     *   Array:
     *     [{content:...}, {content:...}, ...]
     */
    iSliderPrototype.unshiftData = function (sceneData) {
        if (!sceneData) {
            return;
        }

        if (!isArray(sceneData)) {
            sceneData = [sceneData];
        }

        var n = sceneData.length;
        this.data = sceneData.concat(this.data);

        if (this.slideIndex === 0) {
            this._renderItem(this.els[0], n - 1);
        }
        this.slideIndex += n;
    };