meltingice / CamanJS

Javascript HTML5 (Ca)nvas (Man)ipulation
http://camanjs.com
BSD 3-Clause "New" or "Revised" License
3.55k stars 404 forks source link

Handle the slider shows me short time the Original Image #137

Closed pa-he closed 10 years ago

pa-he commented 10 years ago

Hi

I use camanJS with JQuery Slider UI. It works good but if i handle the slider it shows me short time the Original Image without the Effects. I use "revert(). I do not know if this is a bug or something else. Hope you can Help me

Thank you for the GREAT work!

Ps: Is it possible to get a clean code from the example Page?

Slider: // Der SLIDER! $(function() {
var slider = $( "#slider_helligkeit" ).slider({ min: -100, max: 100, value: 0, //123 slide: function (event, ui) { var curVal = ui.value; $('#wert_helligkeit').text(curVal); // show slider value }, stop: function (event, ui) { // when slider stops, perform the function caman_show(); //$( "#wert_helligkeit" ).html( ui.value ); // Wenn der Slider verschoben wird, trägt er die änderung in #wert_helligkeit div element ein.
}, change: function(event, ui) { var sliderValue = $( "#slider_helligkeit" ).slider( "option", "value" ); $('#wert_helligkeit').html(sliderValue); caman_show(); }
});

CamanJS: function caman_show(){ Caman('#myImage', function () { if($('#slider_helligkeit').slider('value')!=0){this.brightness($('#slider_helligkeit').slider('value'));}; // add brightness if($('#slider_kontrast').slider('value')!=0){this.contrast($('#slider_kontrast').slider('value'));}; // add contrast if($('#slider_saettigung').slider('value')!=0){this.saturation($('#slider_saettigung').slider('value'));}; // add saturation if($('#slider_sepia').slider('value')!=0){this.sepia($('#slider_sepia').slider('value'));}; // add sepia if($('#slider_vitalitaet').slider('value')!=0){this.vibrance($('#slider_vitalitaet').slider('value'));}; // add vibrance if($('#slider_farbton').slider('value')!=0){this.hue($('#slider_farbton').slider('value'));}; // add hue if($('#slider_belichtung').slider('value')!=0){this.exposure($('#slider_belichtung').slider('value'));}; // add exposure if($('#slider_gamma').slider('value')!=0){this.gamma($('#slider_gamma').slider('value'));}; // add gamma if($('#slider_rauschen').slider('value')!=0){this.noise($('#slider_rauschen').slider('value'));}; // add noise if($('#slider_clip').slider('value')!=0){this.clip($('#slider_clip').slider('value'));}; // add clip if($('#slider_schaerfen').slider('value')!=0){this.sharpen($('#slider_schaerfen').slider('value'));}; // add sharpen if($('#slider_weichzeichnen').slider('value')!=0){this.stackBlur($('#slider_weichzeichnen').slider('value'));}; // add stackBlur if($('#slider_vignette_1').slider('value')!=0){this.vignette($('#slider_vignette_1').slider('value'),$('#slider_vignette_2').slider('value'));}; // add vignette this.revert(); this.render(); });

     };
meltingice commented 10 years ago

Using the latest version, you can pass false to revert and it will prevent updating the canvas until the next render, thus fixing the original image flash you see.

You can check out the JS for the example page here.

pa-he commented 10 years ago

Thanks, but if i use this.revert(false); I get TypeError: ready.call is not a function

pa-he commented 10 years ago

Ok it works fine with http://cdnjs.cloudflare.com/ajax/libs/camanjs/4.1.2/caman.full.min.js I use 4.0.0 from http://camanjs.com/ , sorry for this!

The Example is written in coffescript. I don't use Coffescript because my Host doesn't support it. If i Convert the Example with http://js2coffee.org/ it doesnt work. Its right that "CamanJS-Site / _assets / javascripts / examples.js.coffee" use in this http://camanjs.com/examples/ page?

What i need is the busy function. if busy changed = true return

Is there some way with JavaScript?

I want add a AJAX Loader.gif, because i use many sliders it takes a while to render the Image. example: If(busy = true){ $( "#ajax_loader" ).show(); }