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

Absolute positioning of objects with JavaScript

Explorer ,
Jan 25, 2017 Jan 25, 2017

Hi,

I`m using Captivate 9 and publish in HTML5.

If I have a classical project (non-responsive) with a specific size, say 1200 x 800 pixels, is there a way to place an object to some specific absolute x-y-position on the screen using JavaScript? For example if I like to place a SmartShape at x=100 and y=200? (Here, x and y could probably depend on a variable).

I know how to place an object relative to its previous position using JS, seeCaptivate scripting - change x & y position of object

Of course I could use this to calculate the respective absolute position, but sometimes it`s easier just to enter the coordinates. This should be possible with JS without using any widget.

Any help is greatly appreciated!

2.0K
Translate
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

People's Champ , Jan 26, 2017 Jan 26, 2017

var myObj = document.getElementById("objectName");

myObj.style.left = varX+"px";

myObj.style.top = varY+"px"

Translate
Enthusiast ,
Jan 25, 2017 Jan 25, 2017

I'm unclear on what you want here - are you looking to lock an object into place in a master slide layout?  The x and y coordinates for any static object on a screen can entered in the properties tab:

Capture

Is there something I'm missing in what you want the object to be able to do with regard to the variables  you mentioned?

Translate
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 25, 2017 Jan 25, 2017

Thank you for the answer! But what I need is to position an object with JavaScript. The position of objects (in my projects) often depend on some other variables.

Say I have two variables var_1 and var_2 (maybe depending on text entry by the user or on other things). Now I want to set the object (SmartShape or whatever) on  X = var_1 and Y = 3*var_2 (just as an example).

Translate
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
People's Champ ,
Jan 26, 2017 Jan 26, 2017

var myObj = document.getElementById("objectName");

myObj.style.left = varX+"px";

myObj.style.top = varY+"px"

Translate
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 26, 2017 Jan 26, 2017

Great! Thank you very much TLC, this worked for me!

Translate
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
New Here ,
Jun 07, 2017 Jun 07, 2017
LATEST

How do you apply javascript to a text caption? Adding a c does not seem to animate it only the shape of the box animates leaving the text at its location

Translate
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
Community Expert ,
Jan 25, 2017 Jan 25, 2017

I am a bit lazy concerning JS. In this case I would use the CpExtra widget by InfoSemantics. It has two variables xcmndPosX and xcmndPosY that can be used for what you are asking here. Much easier, less headaches. Have a look:

http://www.infosemantics.com.au/adobe-captivate-widgets/cpextra/help/command-variables/positioning-s...

Translate
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 25, 2017 Jan 25, 2017

Hi Lilybiri,

my projects had some problems with Edge when I used CpExtra (I think they even say that CpExtra had not been extensively tested with Edge). I want to avoid a widget here as I think positioning of objects should be a standard application for JS.

Translate
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
Community Expert ,
Jan 25, 2017 Jan 25, 2017

True, was one of the testers, and Edge was still pretty new.

It should be possible with JS, but cannot help more.

Translate
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
Contributor ,
Jan 25, 2017 Jan 25, 2017

Hi all,

I am the developer of CpExtra. Since the beta testing phase I know of people who have used CpExtra in the Edge browser without issue. The reason why Edge wasn't supported in the past was because I hadn't access to a computer with the Edge browser and wasn't able to test with it. Now that I do, if someone encounters an issue with CpExtra and Edge they can contact me and I can fix the issue.

So far I know of no outstanding issues with CpExtra and Edge.

Tristan,

Translate
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
Community Expert ,
Jan 26, 2017 Jan 26, 2017

Thanks Tristan. I didn't have any issues in Edge until now.

Translate
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