Skip to main content
Participating Frequently
June 24, 2014
Question

Creating slider to control current layer opacity in HTML?

  • June 24, 2014
  • 1 reply
  • 3726 views

Hi! I wanted to create a slider in custom panel which changes the for eg opacity of the current layer.

Here is what I used in HTML5

<div>

<input type="range" min="0" max="100" value="0" step="1" id="opacity" name="opacity" onChange="sliderChange(this.value)"/>

</div>

Here is the javascript function

$._ext_OPACITY={

      run : function() {

       app.activeDocument.activeLayer.opacity = 50;

    },

};

Now can you please tell me how to link that HTML slider with this function so that user can change the opacity using the slider. Thanks alot.

This topic has been closed for replies.

1 reply

Inspiring
June 24, 2014

You're trying to pass values from HTML to JSX. Davide did a good write up on this a while back: http://www.davidebarranca.com/2014/01/html-panels-tips-4-passing-objects-from-html-to-jsx/

Basically, you need to use CSInterface.evalScript to call your function.

Participating Frequently
June 24, 2014

Yes I want to do this but can you please tell me how to make a slider as I am a noob program basically a designer so it's hard for to understand all the loops etc.

Inspiring
June 24, 2014

Time to learn then! What you are looking for is the range input in HTML. Some examples: http://demosthenes.info/blog/757/Playing-With-The-HTML5-range-Slider-Input