Git Product home page Git Product logo

zoomable's Introduction

Zoomable

Zoomable DOM elements with pinch / double tap / mouse wheel.

Get started:

var zoomable = new Zoomable(document.getElementById("wrapper"), 'img.jpg', {
    gestures: {
        // See ImageMap full example
    },
    zoomMax: 4,
    bound: true
});

ImageMap:

Simple example:

var map = new ImageMap(document.getElementById("wrapper"), 'img.jpg');
var hotspot = map.addHotspot(1500, 900, './hotspot.png');
hotspot.element.addEventListener('click', function(e) {
    console.log("click on hotspot");
});
map.resetZoom(true, 0.75);

Full options example:

var map = new ImageMap(document.getElementById("wrapper"), document.getElementById("myInlineSVG"), {
    gestures: {
        doubleTap: true,
        onDoubleTap: () => {
            console.log('onDoubleTap');
            return false; //Do not execute default action
        },
        pan: true,
        onPan: () => {
            console.log('onPan');
        },
        zoom: true,
        onZoom: () => {
            console.log('onZoom');
        }
    },
    zoomMax: 4,
    bound: true
});

document.getElementById("wrapper").addEventListener('background-ready', function(){
    console.log('background-ready !!');
});

var hotspot = map.addHotspot(1000, 750, './hotspot.png', false, {
    id: "myHotspotId",
    classes: ["plop", "foo", "test"],
    css: {
        zIndex: '12',
        marginTop: '15px'
    },
    data: {
        name: 'hotspot #2',
        whatever: 'This is for the example'
    }
});
hotspot.element.addEventListener('pointerup', function(e) {
    console.log("click on ", this.zoomableData.name);
    console.log(this.zoomableData.whatever);
});

zoomable's People

Contributors

fabsharp avatar

Stargazers

 avatar

Watchers

 avatar  avatar

zoomable's Issues

Double Tap Detect

Sur un petit écran, on a vraiment du mal à détecter le double tap, ça part très vite en "mini pan".
De plus, si on est déjà en mode zoomé, je pense que ça devrait faire un reset du zoom.

Zoom avec hotspots

Faire en sorte que si sur le départ de la gesture pinch, on appuie avec un doigt sur un autre élément à l’intérieur du container, ça zoom quand même (wrapper ?).

ImageMap issues and features

  • ZoomAt(...) centered
  • ZoomAt(...) option for apply translate from initial state
  • add ImageMap.js in dist folder
  • hotspots can be Html Element (not just img)
  • ready event on background img loaded
  • resetZoom function (initial scale end transform)
  • Can enable/disable gestures (pan, zoom, dblTap ...)

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.