IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Visualiser une image avec zoom


Sujet :

JavaScript

  1. #1
    Débutant
    Inscrit en
    Mars 2009
    Messages
    201
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 201
    Points : 62
    Points
    62
    Par défaut Visualiser une image avec zoom
    bonjour,
    j'ai consulter le site
    http://www.dynamicdrive.com/dynamici...agemagnify.htm
    pour appliquer cette tecknique mais elle n'a pas marché je ne sais pas pourquoi
    j'ai fait tout les instructions
    et je n'ai pas compris l'emplacement de l'image magnify.cur
    merci bien

  2. #2
    Expert confirmé
    Avatar de RomainVALERI
    Homme Profil pro
    POOête
    Inscrit en
    Avril 2008
    Messages
    2 652
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : POOête

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 652
    Points : 4 164
    Points
    4 164
    Par défaut
    En nous montrant le bout de code correspondant à ton adaptation du code proposé... peut-être ^^ mais sinon, à part se lancer dans le vaudou ou la méditation transcendentale... je ne vois pas comment deviner

  3. #3
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1
    Par défaut
    En gros tu nous dis :
    "Quand je fais ça, ben ça marche pas ..."

    Je serais tenté de te répondre :
    "Alors essaye ceci ..."

  4. #4
    Débutant
    Inscrit en
    Mars 2009
    Messages
    201
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 201
    Points : 62
    Points
    62
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <script type="text/javascript" src="js/jquery.min.js"></script>
     <script type="text/javascript" src="js/jquery.magnifier.js">
    </script>
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <img src="images/designjet.png" class="magnify" style="width:200px; height:150px" />
    jquery.magnifier.js
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    jQuery.noConflict()
     
    jQuery.imageMagnify={
    	dsettings: {
    		magnifyby: 3, //default increase factor of enlarged image
    		duration: 500, //default duration of animation, in millisec
    		imgopacity: 0.2 //opacify of original image when enlarged image overlays it
     	},
    	cursorcss: 'url(magnify.cur), -moz-zoom-in', //Value for CSS's 'cursor' attribute, added to original image
    	zIndexcounter: 100,
     
    	refreshoffsets:function($window, $target, warpshell){
    		var $offsets=$target.offset()
    		var winattrs={x:$window.scrollLeft(), y:$window.scrollTop(), w:$window.width(), h:$window.height()}
    		warpshell.attrs.x=$offsets.left //update x position of original image relative to page
    		warpshell.attrs.y=$offsets.top
    		warpshell.newattrs.x=winattrs.x+winattrs.w/2-warpshell.newattrs.w/2
    		warpshell.newattrs.y=winattrs.y+winattrs.h/2-warpshell.newattrs.h/2
    		if (warpshell.newattrs.x<winattrs.x+5){ //no space to the left?
    			warpshell.newattrs.x=winattrs.x+5	
    		}
    		else if (warpshell.newattrs.x+warpshell.newattrs.w > winattrs.x+winattrs.w){//no space to the right?
    			warpshell.newattrs.x=winattrs.x+5
    		}
    		if (warpshell.newattrs.y<winattrs.y+5){ //no space at the top?
    			warpshell.newattrs.y=winattrs.y+5
    		}
    	},
     
    	magnify:function($, $target, options){
    		var setting={} //create blank object to store combined settings
    		var setting=jQuery.extend(setting, this.dsettings, options)
    		var attrs=(options.thumbdimensions)? {w:options.thumbdimensions[0], h:options.thumbdimensions[1]} : {w:$target.outerWidth(), h:$target.outerHeight()}
    		var newattrs={}
    		newattrs.w=(setting.magnifyto)? setting.magnifyto : Math.round(attrs.w*setting.magnifyby)
    		newattrs.h=(setting.magnifyto)? Math.round(attrs.h*newattrs.w/attrs.w) : Math.round(attrs.h*setting.magnifyby)
    		$target.css('cursor', jQuery.imageMagnify.cursorcss)
    		if ($target.data('imgshell')){
    			$target.data('imgshell').$clone.remove()
    			$target.css({opacity:1}).unbind('click.magnify')
    		}	
    		var $clone=$target.clone().css({position:'absolute', left:0, top:0, visibility:'hidden', border:'1px solid gray', cursor:'pointer'}).appendTo(document.body)
    		$clone.data('$relatedtarget', $target) //save $target image this enlarged image is associated with
    		$target.data('imgshell', {$clone:$clone, attrs:attrs, newattrs:newattrs})
    		$target.bind('click.magnify', function(e){ //action when original image is clicked on
    			var $this=$(this).css({opacity:setting.imgopacity})
    			var imageinfo=$this.data('imgshell')
    			jQuery.imageMagnify.refreshoffsets($(window), $this, imageinfo) //refresh offset positions of original and warped images
    			var $clone=imageinfo.$clone
    			$clone.stop().css({zIndex:++jQuery.imageMagnify.zIndexcounter, left:imageinfo.attrs.x, top:imageinfo.attrs.y, width:imageinfo.attrs.w, height:imageinfo.attrs.h, opacity:0, visibility:'visible'})
    			.animate({opacity:1, left:imageinfo.newattrs.x, top:imageinfo.newattrs.y, width:imageinfo.newattrs.w, height:imageinfo.newattrs.h}, setting.duration,
    			function(){ //callback function after warping is complete
    				//none added		
    			}) //end animate
    		}) //end click
    		$clone.click(function(e){ //action when magnified image is clicked on
    			var $this=$(this)
    			var imageinfo=$this.data('$relatedtarget').data('imgshell')
    			jQuery.imageMagnify.refreshoffsets($(window), $this.data('$relatedtarget'), imageinfo) //refresh offset positions of original and warped images
    			$this.stop().animate({opacity:0, left:imageinfo.attrs.x, top:imageinfo.attrs.y, width:imageinfo.attrs.w, height:imageinfo.attrs.h},  setting.duration,
    			function(){
    				$this.hide()
    				$this.data('$relatedtarget').css({opacity:1}) //reveal original image
    			}) //end animate
    		}) //end click
    	}
    };
     
    jQuery.fn.imageMagnify=function(options){
    	var $=jQuery
    	return this.each(function(){ //return jQuery obj
    		var $imgref=$(this)
    		if (this.tagName!="IMG")
    			return true //skip to next matched element
    		if (parseInt($imgref.css('width'))>0 && parseInt($imgref.css('height'))>0 || options.thumbdimensions){ //if image has explicit width/height attrs defined
    			jQuery.imageMagnify.magnify($, $imgref, options)
    		}
    		else if (this.complete){ //account for IE not firing image.onload
    			jQuery.imageMagnify.magnify($, $imgref, options)
    		}
    		else{
    			$(this).bind('load', function(){
    				jQuery.imageMagnify.magnify($, $imgref, options)
    			})
    		}
    	})
    };
     
    jQuery.fn.applyMagnifier=function(options){ //dynamic version of imageMagnify() to apply magnify effect to an image dynamically
    	var $=jQuery
    	return this.each(function(){ //return jQuery obj
    		var $imgref=$(this)
    		if (this.tagName!="IMG")
    			return true //skip to next matched element
     
    	})	
     
    };
     
     
    //** The following applies the magnify effect to images with class="magnify" and optional "data-magnifyby" and "data-magnifyduration" attrs
    //** It also looks for links with attr rel="magnify[targetimageid]" and makes them togglers for that image
     
    jQuery(document).ready(function($){
    	var $targets=$('.magnify')
    	$targets.each(function(i){
    		var $target=$(this)
    		var options={}
    		if ($target.attr('data-magnifyto'))
    			options.magnifyto=parseFloat($target.attr('data-magnifyto'))
    		if ($target.attr('data-magnifyby'))
    			options.magnifyby=parseFloat($target.attr('data-magnifyby'))
    		if ($target.attr('data-magnifyduration'))
    			options.duration=parseInt($target.attr('data-magnifyduration'))
    		$target.imageMagnify(options)
    	})
    	var $triggers=$('a[rel^="magnify["]')
    	$triggers.each(function(i){
    		var $trigger=$(this)
    		var targetid=$trigger.attr('rel').match(/\[.+\]/)[0].replace(/[\[\]']/g, '') //parse 'id' from rel='magnify[id]'
    		$trigger.data('magnifyimageid', targetid)
    		$trigger.click(function(e){
    			$('#'+$(this).data('magnifyimageid')).trigger('click.magnify')
    			e.preventDefault()
    		})
    	})
    })

  5. #5
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1
    Par défaut
    Et ?
    tu as un message d'erreur ?
    un comportement particulier ???

  6. #6
    Débutant
    Inscrit en
    Mars 2009
    Messages
    201
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 201
    Points : 62
    Points
    62
    Par défaut
    le probleme c'est qu'il n'ya pas d'erreur sur la page les images sont présents normal comme si il n'ya pas ce code

Discussions similaires

  1. [Article] Appliquer un effet de zoom sur une image avec les CSS
    Par Bovino dans le forum Publications (X)HTML et CSS
    Réponses: 1
    Dernier message: 17/10/2010, 07h53
  2. Appliquer un effet de zoom sur une image avec les CSS
    Par Kerod dans le forum Mise en page CSS
    Réponses: 1
    Dernier message: 17/10/2010, 07h53
  3. Création d'une galerie avec zoom de l'image
    Par Yepes dans le forum Général JavaScript
    Réponses: 6
    Dernier message: 20/09/2008, 15h57
  4. [HTML] Afficher une grosse image avec zoom
    Par Amadou31 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 11
    Dernier message: 08/11/2007, 11h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo