Skip to content

Commit

Permalink
module support
Browse files Browse the repository at this point in the history
  • Loading branch information
worka committed Feb 11, 2020
1 parent ed17bbd commit af2170b
Show file tree
Hide file tree
Showing 5 changed files with 649 additions and 528 deletions.
10 changes: 9 additions & 1 deletion es5/wheel-zoom.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
'use strict';

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

(function JcWheelZoomModule(factory) {
window.JcWheelZoom = factory();
if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined') {
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
define(factory);
} else {
self.JcWheelZoom = factory();
}
})(function JcWheelZoomFactory() {
/**
* @class JcWheelZoom
Expand Down
2 changes: 1 addition & 1 deletion es5/wheel-zoom.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "vanilla-js-wheel-zoom",
"version": "3.0.3",
"version": "3.1.0",
"devDependencies": {
"@babel/cli": "^7.7.7",
"@babel/core": "^7.7.7",
"@babel/preset-env": "^7.7.7",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"babel-minify": "^0.5.1",
"eslint": "^6.8.0"
},
Expand Down
20 changes: 13 additions & 7 deletions src/wheel-zoom.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
'use strict';

(function JcWheelZoomModule(factory) {
window.JcWheelZoom = factory();
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
define(factory);
} else {
self.JcWheelZoom = factory();
}
})(function JcWheelZoomFactory() {
/**
* @class JcWheelZoom
Expand Down Expand Up @@ -99,11 +105,11 @@
this.image.height = this.original.image.height * minScale;

// center the image
this.image.style.marginLeft = `${this.correctX}px`;
this.image.style.marginTop = `${this.correctY}px`;
this.image.style.marginLeft = `${ this.correctX }px`;
this.image.style.marginTop = `${ this.correctY }px`;

this.container.style.width = `${this.image.width + (this.correctX * 2)}px`;
this.container.style.height = `${this.image.height + (this.correctY * 2)}px`;
this.container.style.width = `${ this.image.width + (this.correctX * 2) }px`;
this.container.style.height = `${ this.image.height + (this.correctY * 2) }px`;

if (typeof this.options.prepare === 'function') {
this.options.prepare(minScale, this.correctX, this.correctY);
Expand Down Expand Up @@ -142,8 +148,8 @@
const containerNewWidth = imageNewWidth + (this.correctX * 2);
const containerNewHeight = imageNewHeight + (this.correctY * 2);

this.container.style.width = `${containerNewWidth}px`;
this.container.style.height = `${containerNewHeight}px`;
this.container.style.width = `${ containerNewWidth }px`;
this.container.style.height = `${ containerNewHeight }px`;

if (typeof this.options.rescale === 'function') {
this.options.rescale(newScale, this.correctX, this.correctY, minScale);
Expand Down
Loading

0 comments on commit af2170b

Please sign in to comment.