How to implement jQuery.panzoom with node & browserify

2.1k Views Asked by At

On the plugin's github page there is the following explanation to implement the plugin via AMD loader:

define([ "jquery", "plugins/jquery.panzoom" ], function( $ ) {
  $(document).ready(function() {
    $(".panzoom-elements").panzoom();
  });
});

But how do I implement this plugin via nodejs & browserify?

1

There are 1 best solutions below

4
On BEST ANSWER

This plugin uses UMD (Universal Module Definition) pattern, meaning you could use it also with CommonJS/Browserify module system as usual like any other lib/package.

(See: these lines of source code).

Installation:

npm install jquery.panzoom --save

Usage:

main.js

var $ = require('jquery');
require('jquery.panzoom');

$(document).ready(function() {
  $(".panzoom-elements").panzoom();
});

Browserify:

browserify main.js -o bundle.js