I want to use famo.us standard Scrollview but have a background image which is scrolling at a different speed to give a parallax effect.
Rather than setting up timers and getPosition stuff, i was wondering if there's a way to hook into an event stream, or somehow pipe the Scrollviews position into a transformation that's applied to another object? For example use the modifier within the scrollview and a modifier chain and then apply that to another imageSurface?
The examples are a bit thin here so would appreciate any pointers.
To answer your question, the way to pipe scroll events is to use the sync property of scrollview to get updates on scroll.
That is..
scrollview.sync.on('start',function(e){ // Do Something });
scrollview.sync.on('update',function(e){ // Do Something });
scrollview.sync.on('end',function(e){ // Do Something });
However for rendering objects in sync and ensuring precision on such, I have found the Engine prerender function to be wonderful.
So I would do something like this.
Engine.on('prerender',function(){
// Divide by scalar to get effect
var parallaxEffect = 2.0
var bgPos = -contentScrollview.getPosition() / parallaxEffect;
imageView.state.setTransform(Transform.translate(0,bgPos,0)));
})
Hope these pointers help!
This is a bit of a lazy answer, but let me link you to one of the famous demos created by their HackerLab alumni. It demonstrates using famous to create some complex scrolling/swiping animations.
I've learned a lot about Famo.us from the code in the demos, however this hasn't been made available to those outside the beta list yet. So I cloned the project files.
UltraVisual: A Parallax Scrolling Demo
https://github.com/KraigWalker/famous-UltraVisual
A more advanced scrolling animation demo
https://github.com/KraigWalker/famous-IFTTT
Hope this helps you out!
Related
I want to implement a feature in my react native application to let the user measure area or fields with two different methods the first is manual like manually drawing the fields area in the map and secondly automatically by using the gps and entering points while he walk around the field .
Could please anyone share some resosurces or any help material that may assist me in achieving this feature.
Thanks in advance
It is totally doable. Since you didn't mention any particular library, let me explain using react-native-maps (it is an awesome package :). Let's first discuss using the drawing (not sure if you literally mean drawing - at least I don't think you need to add complexity in this).
You can provide the <MapView> component provided by the package with a onTap method, when the user taps, you can add the coordinate a list of coordinates like this:
const [coordinates, setCoordinates] = useState([]);
then in the map, you can do
<MapView onPress={(coords) => setCoordinates([...coordinates, coords])} ...rest of the code
when the user is done, you can use a bit of mathematics (https://www.mathopenref.com/coordpolygonarea.html) or even a polygon package to calculate the area (https://www.npmjs.com/package/polygon).
Well, the second use case is easier I think as no extra interaction is needed since user can input the coordinates which you can again put in the coordinates array and use to calculate area.
I hope it helps :)
I am working with MapKit on MacOS and trying to enable a draggable annotation that uses a custom image. I can successfully get the annotation to be draggable but it requires the user to be quite accurate with where they click and drag as the annotation image is larger than a conventional pin. Is there a simple way to expand the area so that any part of the image is draggable? Otherwise I imagine I will have to use some kind of NSGesture on the view to manually set the dragstate, but was hoping there might be an easier way!
Okay, I never managed to sort this to my satisfaction using Annotations. I’m not saying it can’t be done, maybe someone else can comment and leave pointers to help. But I eventually achieved what I wanted using overlays instead. So if someone stumbles on this question and has the same issue, you can make it work with a custom overlay rather than an annotation and you implement the dragging using a NSPanGestureRecognizer with translation for the movement.
I'm using Animate CC 2015 and publishing to Canvas.
Can anyone tell me how to apply a tint to an object on my timeline?
The object has been placed there manually and has an instance name. I simply want to change it from white to red using code that runs in the first frame.
On a related note, do you know of a good JS language reference for Animate CC? I always seem to end up on Actionscript references or the CreateJS site which doesn't cater well for stuff that is created manually on the timeline.
Cheers
Have you applied a tint already in Animate? Filters in Canvas are particularly expensive, so by default, Animate will cache items that have filters applied. You have a few options:
Every frame, cache the symbol again. This can be very expensive, but it will work.
Instead of transitioning a single filter, cross-fade between a filtered and non-filtered object. This looks very similar (especially with a tint), and has no performance concerns.
As for JavaScript reference, what exactly are you looking for? Mozilla's MDN reference tends to be the goto place for our team when it comes to raw JavaScript. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
Cheers.
I am thinking to develop some tools for my prototype system. I saw a function in the following link and seems very useful for me as well. But I dont know how to implement it? any idea?
http://www.arcgis.com/home/item.html?id=9c0e319bfaff4d33a0fe2da97c2c3fd7
Thanks!!!
This may not be the most efficient solution, but you could create two viewports, both rendering the scene from the same camera, but before you render the viewport for the right-side half, set the visible flag of walls (and other Mesh objects as necessary) to false, and after rendering the right-side scene reset those flags to true. This wouldn't implement the slider, however.
I have a Bing Map control and I want to animate the location of a pin drawn on the map.
Ideally I'd want to write code like this:
// Image myPin = some Image on the map layer;
var sb = new Storyboard();
var duration = DurationHelper.FromTimeSpan(System.TimeSpan.FromMilliseconds(1000));
sb.Duration = duration;
LocationAnimation ani = new LocationAnimation();
ani.To = new Location(33.3, 11.1); // destination lat, lng
ani.Duration = duration;
sb.Children.Add(ani);
Storyboard.SetTarget(ani, myPin);
Storyboard.SetTargetProperty(ani, "MapLayer.Position");
Resources.Add("moveMyPin", sb);
sb.Begin();
Of course there is no LocationAnimation class in the framework. There are a couple similar: PointAnimation works with the Point type, while DoubleAnimation works with individual double values.
I assumed I have to implement my Timeline-derived class but the documentation I found so far is not helpful in this regard and I don't know where to start.
How to animate a property for which there is no *Animation class ready? Am I missing something?
Update: I think I can do something like
// let aniX and aniY be two DoubleAnimation objects
StoryBoard.SetTargetProperty(aniX, "(MapLayer.Position).Latitude")
StoryBoard.SetTargetProperty(aniY, "(MapLayer.Position).Longitude")
but now I have another problem as I don't see how to animate the attached property and always get an exception like "Cannot resolve TargetProperty (MapLayer.Position).Latitude on specified object."
So I guess the question now becomes: how to specify a property path for an attached property?
Further update: I may be on a wrong lead with the "SetTargetProperty" thing as that would make a dependent animation (see link in comments). Could there be a better way to animate a marker pin to a coordinate destination?
Update 3: as Jared pointed out I could try to animate RenderTransform, or use a transition to achieve my result. I had already gone this way and it doesn't seem to be my solution. This is what I found out:
Using RepositionThemeAnimation, it seems I have to give the new pixel position of the pin. This is problematic for a couple reasons: first, I know the lat/lng destination of the pin, but would have to work out the projection (as far as I can tell there is no public interface to work with projection). Secondly the projection itself can change as the map zooms/pans. The pixel destination at the time of the end of the animation could not be the same as the initial pixel destination. In my scenario it's a major problem as it's very likely the map is moving while the animation is occurring.
Using RepositionThemeTransition all the weird pixel/projection problems went away. It's the only way so far I was able to see the animation I expected. I just set the transition and set the new lat/lng position of the tag (via MapLayer.SetPosition). It has two major problems though. I can't set the duration (nor the easing functions) for the animation. And most importantly I can see no way to execute code when the pin gets to its final position.
Attached properties can be animated, but you must enclose their names in parenthesis. See an example here:
http://www.charlespetzold.com/blog/2007/09/080231.html
However, I believe this only works for setting the whole value (Location) and potentially not sub properties (Latitude and Longitude).
I'm wondering if you can provide more information about what you're trying to do. Is this a temporary animation? i.e. are you wanting the pin to animate in on entrance or departure? If so you can just do an animation on the RenderTransform X and Y instead. You won't actually be changing the location of the pin but you can use the RenderTransform to temporarily change where it's being drawn.
Even better, you might be able to get away with the free animations now built into the framework. You don't even need a storyboard to use them, you just set them right on the element like this:
<Button Content="Transitioning Button">
<Button.Transitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Button.Transitions>
</Button>
For more examples of the animation library and even video previews for many of the animations, see:
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh452703.aspx
Okay, man, your problem isn't related to Bing Maps. It's related to dependency properties that can't be animated UNLESS you specify that they can. Here's how: http://blog.jerrynixon.com/2012/06/windows-8-animated-pie-slice.html
That link in the other answer with Charles' site is not up to date.