Comments (11)
I just added added some UMD boilerplate to add support for requirejs and browserify. I tested with require.js but I haven't used browserify before. Do you have the time to verify that it works with browserify as well?
Grab the latest snabbt.js or snabbt.min.js from master..
from snabbt.js.
Latest release has require.js and browserify support. published to bower and npm
npm install snabbt.js
Unfortunately some trash files was included in the publish, will fix for next release.
from snabbt.js.
Requiring it with browserify is quite quirky. You have to write:
var snabbt = require('snabbt.js').snabbt;
I would expect
var snabbt = require('snabbt.js')
Is that by design?
from snabbt.js.
Yes, it's quirky.
Well, sort of by design. The whole library is in "snabbtjs" namespace. When using without a module loader the snabbt-function is exposed as a global variable.
There is more than the snabbt-function that needs to be accessible, for example the matrix operations. That is why the require call cannot return the snabbt-function directly.
If you want it to work exactly like without the module loader you have to do this:
var snabbt = require('snabbt.js').snabbt;
var snabbtjs = require('snabbt.js');
Do you have any suggestions how it could be improved?
from snabbt.js.
Could you give me an example which externals you need to expose to the user?
from snabbt.js.
To use value feeding for example the Matrix API needs to be accessible.
I've thought about sending them as parameters in the value feed call instead. E.g.
snabbt(element, {
value_feeder: function(i, ident, mult, trans, rotX, rotY, rotZ, scale, skew) {
return mult(trans(100*i, 0, 0), rotX(2*Math.PI));
}
}
I don't know how I feel about this, but at least it would allow for export of only the snabbt function..
from snabbt.js.
I understand. That many parameters are tricky and very verbose for the developer when he just needs scale. Another option would be to pass a $scope object that exposes the MatrixAPI as an object where mult, trans, ... are attributes.
Since value_feeder is a function another option would be to call it via call
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call) instead of calling value_feeder(tween_value) and provide a context with the scope variables. The user could use it like this:
snabbt(element, {
value_feeder: function(i) {
return this.mult(this.trans(100*i, 0, 0), this.rotX(2*Math.PI));
}
}
But it might feel like to much magic.
from snabbt.js.
Great input.
I think I prefer the first approach, it's more explicit.
Even better would be to redesign the Matrix API so that the operations are instance methods returning this
. Then the second parameter could be an identity matrix and all the operations could be chained on that:
snabbt(element, {
value_feeder: function(i, matrix) {
return matrix.trans(100*i, 0, 0).rotX(2*Math.PI);
}
}
And while I'm at it I think I will get rid of the silly abbreviations. trans -> translate, rotX -> rotateX etc..
I'll sleep on it but I think this is the way to go.
Thoughts?
from snabbt.js.
Great idea. Go for it.
from snabbt.js.
Fixed in the latest release
from snabbt.js.
👍 Thanks!
from snabbt.js.
Related Issues (20)
- Allow adding extra transforms to output HOT 3
- Nice work. HOT 1
- Add sane examples HOT 4
- Moving to ES6
- allDone and complete is not fired with duration: 0 HOT 5
- simple error report HOT 2
- Snabbt and Hammer.js HOT 1
- npm does not install all required dependecies HOT 3
- Stop callback HOT 2
- cubic-bezier easing HOT 1
- Manual mode code snippet
- Opacity with delay
- Don't work on iphone4 safari and some Android browsers. HOT 2
- Issue with animations seemlingly affecting one another
- Duration is broken for manual mode?
- Error: Cannot find module './utils.js from snabbt.js'
- safari 8
- Change naming scheme? HOT 1
- Remove animation from element
- Attention animations not fire complete and allDone event
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from snabbt.js.