2011-08-11 1 views
2

私はJavaScriptでPixasticプラグインを使用しています。私は、ぼやけた画像でいっぱいのテーブルを持っています。私はマウスでそれらを乗り越えるとき、彼らは正常になることを望みます。そして、マウスが画像を残すとき、私はそれがぼやけていることを望みます。何らかの理由で私のコードが動作しません。コードは次のとおりです:画像のクラスでPixasticと.liveを使用する

前に、私は間違ったコード部分をコピーしました。私はこれが私が求めているものであることをお詫びします。

<script type="text/javascript"> 
    $(document).ready(function(){ 
     $('.photography').live('mouseover mouseout', function(event) { 
      if (event.type == 'mouseover') { 
       function() {Pixastic.revert('this');}; 
      } 
      else { 
       function(){Pixastic.process('this', "blurfast", {amount:0.5});}; 
      } 
     }); 
    }); 
</script> 

OKなので、(私はそれが動作する初めての画像にカーソルを合わせると、私はそれがない第二の時間のためにしようとすると)私は実際には半分のように動作します私の古いコードを見つけることができました。

$(document).ready(function(){ 
    var blur = function() {Pixastic.process(this, "blurfast", {amount:0.5});}; 
    var unblur = function() {Pixastic.revert(this);}; 
    $('.photography').each(blur); 
    $('.photography').hover(unblur,blur); 
}); 

OK、今、私はまた、関数のコードを追加しているがrevertと呼ばれる:

revert : function(img) { 
    if (Pixastic.Client.hasCanvas()) { 
     if (img.tagName.toLowerCase() == "canvas" && img.__pixastic_org_image) { 
      img.width = img.__pixastic_org_width; 
      img.height = img.__pixastic_org_height; 
      img.getContext("2d").drawImage(img.__pixastic_org_image, 0, 0); 

      if (img.parentNode && img.parentNode.replaceChild) { 
       img.parentNode.replaceChild(img.__pixastic_org_image, img);; 
      } 
      return img; 
     } 
    } 
    else 
     if (Pixastic.Client.isIE()) { 
      if (typeof img.__pixastic_org_style != "undefined") 
       img.style.cssText = img.__pixastic_org_style; 
      } 
     } 
+0

多分あなたは文字列の代わりに 'this'を渡すはずですか? ( ''this'') –

+0

これはうまくいきませんでした – a13ks

答えて

3

をやってみだから、昨日、私の友人は、これは可能性がどのように発見しました完了...問題は、プラグインがキャンバスに画像を変換するということでしたが、とにかく彼女はコードです:

$(document).ready(function(){ 

    $('.pic').each(function(){ 
     this.onmouseout = function(){ 
      var canvas1 = Pixastic.process(this, "blurfast", {amount:0.5}); 
      canvas1.onmouseover = function(){ 
       Pixastic.revert(this); 

      } 
     } 

     this.onload = function(){ 
      var canvas = Pixastic.process(this, "blurfast", {amount:0.5}); 
      canvas.onmouseover = function(){ 
       Pixastic.revert(this); 

      } 
     } 
    }); 
}); 
0

この

$('.photography').live('mouseenter', function(event){ 
    Pixastic.revert(this); 
}).live('mouseleave', function(event){ 
    Pixastic.process(this, "blurfast", {amount:0.5}); 
}); 
+0

あなたはどんなエラーを出していますか?あなたはコードを進めることができますか?それはマウスセンター機能の中で踏み込んでいますか? –

+0

よく私は前にonhoverといくつかのコードを使用して問題を抱えていないエラーを取得しないで、それは一度働いた(私はマウスで画像を上に行くと私はそれを残して、私はそのコードを見つけたらそれを見つけるでしょう... – a13ks

+0

私はそれを更新しましたが、私は最初のものが正しいと思います(私はjs警告で試しました;)それは私がdivをクリックした画像にアクセスする方法を知らないということです... – a13ks

関連する問題