Giter Club home page Giter Club logo

jquery.pan's Introduction

Howdy! πŸ‘‹

⚑ I'm Jose Alarcón, from rainy Galicia, in the northwest of Spain (Europe). I'm an engineer, entrepeneur, writer and speaker.

πŸ’» My code is mainly focused in 🌐 Web develoment: Front-End with JavaScript, and backend with C# and the .NET Framework, although I do a lot of this and that with other langs, frameworks and tools.

πŸ’¬ Ask me about anything related to online training in Spain, which is what I do for a living.

πŸ“« You can reach me through:

My basic stats on GitHub

These are my highlighted Open Source projects at GitHub:

jquery.pan's People

Contributors

jmalarcon avatar mobcode100 avatar rgbjoy avatar saplumbaga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jquery.pan's Issues

Different axis move depending on image orientation (landscape/portrait)

Hi
Quick question:
Would it possible to change/block the axis move depending on image orientation?
To be more precise, I'd like to:
β€” allow the horizontal axis move/block the vertical axis move for landscape images (the image height would be the viewport height)
β€” allow the vertical axis move/block the horizontal axis move on portrait image (the image width would be the viewport width).

Great fork btw πŸ‘

Extended for Rotation

Found this tool to be super useful, quick, elegant, and extremely simple to use. However, many of the images we deal with in web apps on a day-to-day basis originate as scans which can arrive in unpredictable orientations, so the lack of rotation capability was a pain point for us. So I made a few quick additions to your code to allow for rotation and will attach them here. Also updated the control icons to make them a bit more visible since we found the original controls were too hard for many users to spot.

Extracting the current transition state directly from CSS styles is difficult, so the rotation functions which I've added lean on storing the current rotation state in a 'data-' attribute of the 'PanImg' element. This has the added benefit of your preferred rotation being sustained throughout a page session even if you close the image previewer and return to it later.

I haven't done much in the way of platform testing the additions, but verified they work as expected on at least Chrome (79), IE(11), Edge, and Droid Chrome. Rather than fork your project - just passing along my adjustments and will leave it up to you if you think they are worth inclusion in an update, or inspire something similar of your own making.

zoomOut
close
rotateAntiClockwz
rotateClockwz
zoomIn

Additions to jquery.pan.css:

.panWrapper a.controls.rc {
    background-image: url('img/rotateClockwz.png');
    margin-left: 60px;
}

.panWrapper a.controls.ra {
    background-image: url('img/rotateAntiClockwz.png');
    margin-left: -60px;
}

Additions to jquery.pan.js:
icon instantiations

		var rc = document.createElement('a');
		$(rc).addClass("controls rc");
		$(panWrapper).append(rc);

		var ra = document.createElement('a');
		$(ra).addClass("controls ra");
		$(panWrapper).append(ra);

and two new functions

		$(rc).click(function (e) {
			var panImg = $(".panWrapper img.i");
			var angle = (panImg.data('rotAngle')) || 0;
			angle += 90;
			if(angle > 360){angle = angle-360};
			panImg.css({'transform' : 'rotate(' + angle + 'deg)'});
			panImg.data('rotAngle', angle);
			panInit(e);
		});

		$(ra).click(function (e) {
			var panImg = $(".panWrapper img.i");
			var angle = (panImg.data('rotAngle')) || 0;
			angle -= 90;
			if(angle < 360){angle = angle+360};
			panImg.css({'transform' : 'rotate(' + angle + 'deg)'});
			panImg.data('rotAngle', angle);
			panInit(e);
		});

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.