Skip to content

Commit 04edafd

Browse files
committed
Merge pull request #17 from imgix/umd-output
UMD Output
2 parents 7c8574d + 3a1519f commit 04edafd

File tree

7 files changed

+16
-27
lines changed

7 files changed

+16
-27
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Easily add "zoom on hover" functionality to your site's images. Lightweight, no-
1919
* **Bower**: `bower install drift`
2020
* **Manual**: [Download](https://github.com/imgix/drift/archive/master.zip) and use `dist/Drift.min.js` or `dist/Drift.js`
2121

22+
If your build process will re-run `dist/Drift.js` or `dist/Drift.min.js` through Browserify, you'll need to add `noParse: ['drift-zoom']` to your Browserify config. If you skip this, Browserify will attempt to re-require Drift's dependencies which have already been inlined.
23+
2224

2325
<a name="usage"></a>
2426
## Usage

dist/Drift.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2-
(function (global){
1+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Drift = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
32
'use strict';
43

54
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
65

7-
Object.defineProperty(exports, "__esModule", {
8-
value: true
9-
});
10-
exports.VERSION = undefined;
11-
126
var _dom = require('./util/dom');
137

148
var _injectBaseStylesheet = require('./injectBaseStylesheet');
@@ -27,16 +21,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
2721

2822
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2923

30-
var VERSION = exports.VERSION = '0.1.6';
31-
32-
var Drift = (function () {
24+
module.exports = (function () {
3325
function Drift(triggerEl) {
3426
var _this = this;
3527

3628
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
3729

3830
_classCallCheck(this, Drift);
3931

32+
this.VERSION = '0.1.6';
33+
4034
this.destroy = function () {
4135
_this.trigger._unbindEvents();
4236
};
@@ -173,11 +167,6 @@ var Drift = (function () {
173167
return Drift;
174168
})();
175169

176-
exports.default = Drift;
177-
178-
global.Drift = Drift;
179-
180-
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
181170
},{"./Trigger":2,"./ZoomPane":3,"./injectBaseStylesheet":4,"./util/dom":5}],2:[function(require,module,exports){
182171
'use strict';
183172

@@ -338,7 +327,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
338327

339328
// All officially-supported browsers have this, but it's easy to
340329
// account for, just in case.
341-
var HAS_ANIMATION = 'animation' in document.createElement('div').style;
330+
var HAS_ANIMATION = typeof document === 'undefined' ? false : 'animation' in document.createElement('div').style;
342331

343332
var ZoomPane = (function () {
344333
function ZoomPane() {
@@ -633,4 +622,5 @@ function throwIfMissing() {
633622
throw new Error('Missing parameter');
634623
}
635624

636-
},{}]},{},[1]);
625+
},{}]},{},[1])(1)
626+
});

dist/Drift.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ gulp.task('test-full', function(done) {
6868

6969
gulp.task('build-js', function() {
7070
var b = browserify({
71+
standalone: 'Drift',
7172
entries: paths.jsEntry,
7273
transform: [babelify]
7374
}).bundle();

src/js/Drift.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import injectBaseStylesheet from './injectBaseStylesheet';
44
import Trigger from './Trigger';
55
import ZoomPane from './ZoomPane';
66

7-
export const VERSION = '0.1.6';
7+
module.exports = class Drift {
8+
VERSION = '0.1.6'
89

9-
export default class Drift {
1010
constructor(triggerEl, options = {}) {
1111
this.triggerEl = triggerEl;
1212

@@ -113,5 +113,3 @@ export default class Drift {
113113
this.trigger._unbindEvents();
114114
};
115115
}
116-
117-
global.Drift = Drift;

src/js/ZoomPane.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { addClasses, removeClasses } from './util/dom';
33

44
// All officially-supported browsers have this, but it's easy to
55
// account for, just in case.
6-
const HAS_ANIMATION = 'animation' in document.createElement('div').style;
6+
const HAS_ANIMATION = typeof document === 'undefined' ?
7+
false :
8+
'animation' in document.createElement('div').style;
79

810
export default class ZoomPane {
911
constructor(options = {}) {

test/testDrift.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ afterEach(function() {
1717
});
1818

1919
describe('Core', () => {
20-
it('exposes `Drift` on `window`', () => {
21-
expect(window.Drift).toBeDefined();
22-
});
23-
2420
it('throws if no arguments are passed', () => {
2521
expect(() => {
2622
new Drift;

0 commit comments

Comments
 (0)