Comments (5)
fa-size
and fa-origin
should both work on fa-modifier
. Only fa-size
is supported on a Surface
—I don't believe origin
is a supported option on a Famo.us Surface
, see documentation:
famous/core/Surface.js
/**
* A base class for viewable content and event
* targets inside a Famo.us application, containing a renderable document
* fragment. Like an HTML div, it can accept internal markup,
* properties, classes, and handle events.
*
* @class Surface
* @constructor
*
* @param {Object} [options] default option overrides
* @param {Array.Number} [options.size] [width, height] in pixels
* @param {Array.string} [options.classes] CSS classes to set on inner content
* @param {Array} [options.properties] string dictionary of HTML attributes to set on target div
* @param {string} [options.content] inner (HTML) content of surface
*/
fa-size
on a fa-modifier
might not do quite what you expect — I've found that fa-scale
tends to be more useful. I usually add fa-size
to surfaces/views only, then deal with scaling on modifiers with fa-scale
.
One more thing, if you run into other issues with fa-modifier
(there're a couple known issues, like not being able to specify the order of matrix-multiplied transforms) two catch-all options are to 1. nest subsequent fa-modifier
s with one transform per modifier, or 2. create a custom Famo.us Transform object in your controller, then pass it to fa-modifier
using the fa-transform
attribute.
from famous-angular.
The issue is with getting it to respond to changes. For example this snippet from the home page, extended with origin and size:
<input type="range" ng-model="translateX">
<fa-modifier fa-translate="[translateX, 0]" fa-origin="[translateX,40]>
<fa-surface fa-size="[translateX, 40]" class="square">
</fa-surface>
</fa-modifier>
doesn't work as I expect.
from famous-angular.
Ah, I see—you are right, this is not yet implemented (currently it will $eval what you pass in only once, meaning only passing function references is supported if you want dynamic behavior.) Just added a high-priority task to our tracker; we should add the ability to do normal data-binding shortly.
In the meantime, you can pass a function reference (which, incidentally, is the highest-performance way to deal with updates; makes Angular only have to dirty-check the reference to the function, not the value that it's returning.) For example:
controller.js
var _size = [20, 50];
$scope.mySizeFunction(){
return _size;
}
//mutate _size elsewhere
template.html
<fa-modifier fa-size="mySizeFunction">...</fa-modifier>
One other note: famous Surfaces don't support the same functional approach that Modifiers do in setting attributes—you can only set a Surface's size to an array, not to a function returning an array. We could support data-binding to surfaces' fa-size, but it would not be as performant as passing a function directly to fa-size on a modifier (prefer doing the latter, setting the surface's size to [undefined, undefined] and letting it fill its parent modifier.)
So, due to the fact that you're updating the size over time (and thus contrary to what I wrote two comments ago, sorry for the run-around!) the best approach at the moment would be:
- Use fa-size on an fa-modifier, and pass it the name of a function sitting on your scope that returns your desired size
- Add a fa-surface with fa-size="[undefined, undefined]" (same as omitting fa-size) to fill the modifier.
Thank you for your persistence in reporting this. Does this approach work for you?
from famous-angular.
Thanks, this way it works. Good to know about the performance benefits, thanks for the thorough answers 👍
from famous-angular.
With 0.0.12 (latest version, just released,) you can now pass normal expressions to a fa-modifier's fa-size (like fa-size="[sizeX(), sizeY()]"
), and same for fa-origin. You can also still use the functional approach fa-size="myFunc"
and you can pass in a Transitionable fa-size="myTransitionable"
.)
Further, there's no longer a performance difference between any of these methods (we're using Angular's $parse
to handle this more efficiently now instead of running a bunch of scope.$eval
s on every frame.)
from famous-angular.
Related Issues (20)
- Famous js is dead? The last commit Mar 22! HOT 2
- Issue with the container-surface and/or the z-plane HOT 1
- Scrolling on Mobile not working HOT 1
- fa-tap not working
- Famous-angular + Angular-material(ngMaterial) issues
- famous-angular, does it work with typescript? HOT 4
- Question: famo.us-angular and nested views HOT 1
- Ui-Router without explicitly set z dimension reorders after transition
- Ng-Infinite-Scroll does not work well with Famo.us/Angular surfaces hidden by ngShow HOT 1
- Famous-angular New Famous Engine with mixed mode status? HOT 24
- NavigationBar moreContent change bug
- faEdgeSwapper element reversal?
- fa-container-surface doesn't accept fa-size
- Website fail HOT 4
- Famous:Angular 0 5 2 with Ionic input cursor bug on animation
- faScrollView disapears when paginated = true on dragging (not mouse scrolling) HOT 4
- Famo.us + Angular2? How hard is it? HOT 3
- famous
- This lack of information.... HOT 1
- Can famous work with Angular-v2 HOT 1
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 famous-angular.