frameModule.topmost().goBack()
When I call above, the page switches right away w/o animation.
Anyway to get it to slide or something?
There is animated in NativeScript Frame module API:
frameModule.topmost().animated = true;
http://docs.nativescript.org/api-reference/classes/_ui_frame_.frame.html#animated
Related
How do I force a redraw of canvas api ?
I have a js button which I want to force a redraw when clicking.
It only redraws after I hover on the canvas.
Have access to canvas and ctx in js.
I can't say for certain without seeing your code but I think you could simply take the function being called in the canvas onhover and use that same function for your button using the onclick attribute.
I'm working on a basic design app where the user can upload images to a canvas, drag them around and resize them. The problem I have is resizing the image with a mouse drag. I'd like the user to position the mouse pointer on either corner of the bitmap image and drag either towards or away from the bitmap to resize it proportionally. I'd be grateful for any code or suggestions.
Lanny mentioned that you had this question here. ZIM, which is based on CreateJS has this functionality built in - it is called transform(). We also have an uploader built in called Loader().
Here is the code that you would use inside the ZIM template available on the code page at ZIM https://zimjs.com
const loader = new Loader().center();
loader.on("loaded", e=>{
e.bitmap.center().transform();
// or if you want multiple files
// loop(e.bitmaps, bitmap=>{
// bitmap.center().transform();
// });
loader.removeFrom();
stage.update();
});
Below is an image that has been loaded. You can try it here https://zimjs.com/explore/uploadresize.html. The transform interface will go away when the user clicks off the image and then comes back when they click on the image. There are various options for all of this that you can read about in the Docs available on the ZIM site.
All your regular CreateJS will work and you will find that ZIM is helpful in many other ways too! Aside from transform() there is drag() for normal dragging, and gesture() for pinch zoom and rotate - you would use one or the other of these not combined.
I have incorportated an Animate CC animation into my website. I need to pause it until the user scrolls to that section. I've tried using waypoints.js and it animated the object in but the animation has already run it's course. Is there a way to pause it until it's in the viewport?
Check this out:
https://github.com/UseAllFive/true-visibility
You could have this.stop(); at the very start of your animation and use:
var my_element = document.getElementById('my-element');
//-- Returns true/false
my_element.isVisible(my_element);
Assuming your canvas animation is called my_element, you can simply play the timeline if it returns true.
I'm developing a scaling web page with three image-based layers of parallax scrolling. Only the first two layers are set up with parallax javascript. The third layer is set at normal scroll speed 0, so it doesn't require any scroll speed modification.
My problem is that when the page is reloaded (on Firefox, at least) when you aren't at the top of the page, those two layers load in the wrong place, but then correct themselves once you start scrolling.
I believe the problem has something to do with the position attribute. Changing to "relative" has the same effect, changing to "fixed" has a similar effect (except on reloading, the layers act like the top of the viewport is the top of the page), and having no position attribute causes them to not be layered and not have a parallax scrolling effect.
This is the javascript I'm using for the parallax effect:
$(window).scroll(function(e){
parallax();
});
function parallax(){
var scrolled = $(window).scrollTop();
$('.bg').css('top',-(scrolled*-0.7)+'px');
$('.stairs').css('top',-(scrolled*-0.5)+'px');
}
And here's a simplified version of my page with placeholder graphics on a jfiddle: http://jsfiddle.net/4spur9ch/
You can see what I mean by slightly scrolling down, then right clicking inside the result box, then going to This Frame > Reload Frame
This is the last kink that needs to be worked out before I can continue. Any help would be greatly appreciated.
Edit: It's possible it could have something to do with the 'top' in the javascript, but removing it causes problems.
$(window).scroll(function(e){
parallax();
});
/*Needed to add this line:*/
$(window).trigger("scroll")
function parallax(){
var scrolled = $(window).scrollTop();
$('.bg').css('top',-(scrolled*-0.7)+'px');
$('.stairs').css('top',-(scrolled*0.3)+'px');
}
I'm having trouble using easelJS to render Bitmap in IE9. Every other browser renders the image fine, but IE9 canvas is blank. I even tried preload the image in a hidden div and it still doesn't work. here's my code, help please!
function init(){
var canvas = document.getElementById('myCanvas');
var stage = new createjs.Stage(canvas);
var ship= new createjs.Bitmap(ship.png);
stage.addChild(ship);
}
You need to call stage.update() after adding the child. Also, you'll need to wait until the image is fully loaded. Check out PreloadJS, by the makers of EaselJS to help you handle this.