Giter Site home page Giter Site logo

customphotoswipe's Introduction

Introduction

This is an extension of PhotoSwipe, new features added:

  • (return boolean) prependItems/appendItems(Array): prepend/append/remove items and will keep current state of current slide. Can only be successful when !_mainScrollAnimating. When append/prepend/remove failed, please retry in your project. Recommend using this api in the mainScrollAnimComplete event callback.
  • Add Matrix mode, automatically enable on android, improve scaling performance.
  • Enable scaling rich text html.
  • goToAnimated: animated flip page(-1/1).
  • Some improvements in QQBrowser which embedded in android QQ or wechat.

QQ Comic Reader: Flip mode

References

Usage

  • Link stylesheet ./css/default-skin.css and ./css/photoswipe.css
  • Insert script ./js/CustomPhotoSwipe-4.1.1.js
  • Run page
var pswpElement = document.querySelectorAll('.pswp')[0];

// build items array
var items = [
    {
        html: '<div style="background-image: url(https://placekitten.com/1200/900)"></div>',
        w: 1200,
        h: 900
    }
];

// define options (if needed)
var options = {
    // optionName: 'option value'
    // for example:
    index: 0 // start at first slide
};

// Initializes and opens PhotoSwipe
var gallery = new PhotoSwipe(pswpElement, null, items, options);
gallery.init();

setTimeout(function () {
    var appendQueue = [];

    for (var i = 0; i < 5; i ++) {
        appendQueue.push({
            html: '<div style="background-image: url(https://placekitten.com/1200/900)"></div>',
            w: 1200,
            h: 900
        });
    }

    if (gallery) {
        // Dynamic append/prepend/remove only can work during `mainScrollAnimComplete`
        // gallery.listen('mainScrollAnimComplete', function () {
        // 	if (gallery) {
        // 		if (appendQueue.length > 0 && gallery.appendItems(appendQueue)) {
        // 			appendQueue = [];
        // 		}
        // 	}
        // });
        if (appendQueue.length > 0 && gallery.prependItems(appendQueue)) {
            appendQueue = [];
        }
    }
}, 3000);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.