13 Replies
Gaston RAPARIVO

Hi all, If someone is still looking for a solution. You can do it with a picture (it's easier to get the element with the filename of the picture) and JavaScript. Below is the JavaScript code for rotation and you can see the code for scale in the attached file.

var elem = null;
var slide = parent.document.getElementById('slide');
var divs = slide.querySelectorAll('div');

for (var i in divs) {
if (divs[i].tagName == "DIV") {
// data-acc-text attribute contains the filename
var attr = divs[i].getAttribute('data-acc-text');
// eg. avatar.png is the filename of the picture
if (attr && attr=='avatar.png') {
elem = divs[i];
break;
}
}
}

if (elem) {
var style = window.getComputedStyle(elem);
var matrix = style.transform.match(/matrix.*\((.+)\)/)[1];
var values = matrix.split(', ');
// scale value
var s = Math.sqrt(values[0]*values[0] + values[1]*values[1]);
var player = GetPlayer();
// angle from the slider
var r = player.GetVar('rotationValue') ;
elem.style.transform = "translate("+values[4]+"px, "+values[5]+"px) rotate("+r+"deg) scale("+s+")";
}
Emma Clayton

Hi Gaston

Thanks for the demo file, I'd love to adjust it for a project I'm working on. I've tried copying and pasting the .png and the sliders into a new .story file so that I can play with them but it doesn't work when I publish it. The variables and triggers have copied across. Just wondering what it is I've missed.

Math Notermans

Just changed Gaston's version to use GSAP as that is build into Storyline360. Gives many more possibilities too... like easing and more.

This was the original code...
var elem = null;
var slide = parent.document.getElementById('slide');
var divs = slide.querySelectorAll('div');

for (var i in divs) {
    if (divs[i].tagName == "DIV") {
        var attr = divs[i].getAttribute('data-acc-text');
        if (attr && attr=='avatar.png') {
            elem =  divs[i];
            break;
        }
    }
}

if (elem) {
    var style = window.getComputedStyle(elem);
    var matrix = style.transform.match(/matrix.*\((.+)\)/)[1];
    var values = matrix.split(', ');
    var r = Math.round(Math.asin(values[1]) * (180/Math.PI));
    var player = GetPlayer();
    var s = player.GetVar('scaleValue') ;
    elem.style.transform = "translate("+values[4]+"px, "+values[5]+"px) rotate("+r+"deg) scale("+s+")";
}

And this is the same but then using GSAP.
As you can see...shorter and simpler.


//this needs to be the 'acc-name' of the image
let imageToChange = document.querySelector("[data-acc-text='avatar.png']");

let player = GetPlayer();
let s = player.GetVar('scaleValue');
gsap.to(imageToChange, { duration:0.1,scale: s });

Added the adapted version.

Math Notermans

And as the original question of this post was about shapes...

https://360.articulate.com/review/content/be8724c6-9fcd-42de-854f-554042ded54f/review

I added a shape scale and rotation to it. Toggling the checkboxes x and y you can scale it accordingly.

PS. this was already possible in Storyline 1, allthough getting Javascript to work was way more complex.

Math Notermans

True...even better then to use gsap.set
gsap.set(imageToChange,{scale:s});

Used to the syntax... and it makes it easier to add eases or anything else.
GSAP is really magical.
https://greensock.com/

And luckily Articulate is now quite aware of its power...they update it now regularly.
The latest version 3.10.4 is active in Storyline360