• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Javascript - set success for an object

Explorer ,
Jan 09, 2020 Jan 09, 2020

Copy link to clipboard

Copied

I'm trying to set success for a clickbox based on a mouse event using javascript, but can't find anywhere in the API documentation that says that might be possible. 

Reading up as much as I can, I'm thinking something like this might work...

document.getElementById(“Click1”).addEventListener(“mouseover”, ..........);

where the ........ is something that sets click 1 to success, and does whatever the success option is for that clickbox.

Any pointers would be appreciated. Thanks!

TOPICS
Advanced

Views

536

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Jan 13, 2020 Jan 13, 2020

So you want to use the scrollwheel to navigate slides but only for one particular slide?

If that is the case, you can just wrap this up in an if statement for the slide you want to perform this on.

$(window).on("wheel", function(event){

if (cpInfoCurrentSlide==2) {

  if(event.originalEvent.deltaY < 0){
window.cpAPIInterface.next();
  }
  else {
window.cpAPIInterface.previous();
  }
}
});

 

Votes

Translate

Translate
Advisor ,
Jan 09, 2020 Jan 09, 2020

Copy link to clipboard

Copied

If I think I understand correctly - here is what I do.

 

Suppose I have a click box on the screen named box1 and an assigned action.

This javascript works to magically click that box for you when run.

var box = $('#box1')[0];
cp.clickHandler(box);

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2020 Jan 09, 2020

Copy link to clipboard

Copied

Thanks so much for the quick reply.

So, that would "click" the box at runtime?

 

I'm looking for an eventlistener, so that the user can still initiate the action, ideally with a mousewheel movement... but I'd be happy to figure out the code for just a mouseover even, and then I can play with getting the wheel to work.

 

Perhaps I've been unclear because I used a clickbox object. Doesn't matter the object - happy to use a button too - whatever works! Am I making sense?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 10, 2020 Jan 10, 2020

Copy link to clipboard

Copied

If you are looking for a mousewheel action to trigger an effect, try playing with this.

In this example, I would place this code as an onEnter Execute JavaScript success action for the slide.

Then I have a simple star shape on the stage named  star

Scrolling up will show the star and scrolling down with the mouse wheel will hide the star.

Simply replace the  cp.show("star"); and cp.hide("star");  commands with what you want to do.

 

Hope this helps.

$(window).on("wheel", function(event){

  if(event.originalEvent.deltaY < 0){
cp.show("star");
  }
  else {
cp.hide("star");
  }
});

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 12, 2020 Jan 12, 2020

Copy link to clipboard

Copied

Thanks so much! I put in these actions instead...

 

$(window).on("wheel", function(event){ if(event.originalEvent.deltaY < 0){ window.cpAPIInterface.next(); } else { window.cpAPIInterface.previous(); } });

 

Which works great... except if I keep using my wheel up, I just scroll through the whole project (past all the timed buttons etc...). Is there any way to make this apply to the current slide only... or better still just when I rollover a particular smartshape/object?

 

Really appreciate your help! Feel free to tell me to go away! Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 13, 2020 Jan 13, 2020

Copy link to clipboard

Copied

So you want to use the scrollwheel to navigate slides but only for one particular slide?

If that is the case, you can just wrap this up in an if statement for the slide you want to perform this on.

$(window).on("wheel", function(event){

if (cpInfoCurrentSlide==2) {

  if(event.originalEvent.deltaY < 0){
window.cpAPIInterface.next();
  }
  else {
window.cpAPIInterface.previous();
  }
}
});

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 15, 2020 Jan 15, 2020

Copy link to clipboard

Copied

LATEST

Thanks this worked perfectly. Really appreciate your help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources