Problem: Does the Show() toggle the Display?
Saola Animate version: v3.0.1
OS: win10
Notes:
User manual “Chapter 15: JavaScript” mentions about an API named “show(”
but this manual does not mention about which option will be turn on/off by it.
Q1) Does the Show() toggle the Display property on the Properties, General, Display?
Q2) Does API of Saola alos case-sensitive?
Hope new user manual mentions about every option to turn on/off by an API.
Yes, show() toggles the Display property.
All APIs are case-sensitive.
You can set many element properties by using the (undocumented) setProperty method.
For example:
var element = doc.getElement('Div_1');
// set a single property:
element.setProperty('left', '50%');
element.setProperty('width', 300); // same as element.setProperty('width', '300px');
// set multiple properties at once:
element.setProperty({
left: '50%',
width: 300,
rotateZ: 30, // degree
opacity: 50 // %
});
You can use fillLinearGradient(angle, stops) function to change the linear gradient fill. stops is an array of gradient stops, each stop is an array of stop position (in %) and color components (red, green, blue, alpha in the range 0 - 255).
For example:
// fill linear gradient from red at bottom to blue at top
// each stop: [position, red, green, blue, alpha]
var stop1 = [0, 255, 0, 0, 255]; // red
var stop2 = [100, 0, 0, 255, 255]; // blue
var angle = 0;
doc.getElement('Div_1').fillLinearGradient(angle, [stop1, stop2]);
You can add that code to any event, provided that the element is available when the event occurs.
For example, you can add it to a Run JavaScript action in the Mouse Click event of the element.
Whenever the user clicks the element in HTML5 output or preview, the element position and size will be logged to the browser console (press F12 in the browser to show its console).
You may need to take a look at this event-action tutorial:
As you can see, no matter where the ball is, the (left, top) always be (0, 32),
and I need to know the position of the element.
for example, my scene size is 400x300,
and the position of the ball above is (Left=200, Top=150).
It’s just an example.
You should google how to get a specific property from a HTML element, or view the MDN Web Docs page mentioned above.
offsetLeft, offsetTop doesn’t take transformation (translation, scaling, rotation) into account.
In your case, the ball has a motion path animation that use translation, you can use getComputedStyle(node).transform to get the transformation matrix. After that, try to get the translation from the matrix. It’s not simple so you may need to google for a code snippet to do that.
You can also use node.getBoundingClientRect but this method take all transformations (from the root element to the node) into account.