Foros del Web » Programando para Internet » Javascript »

DragAndDrop propiedad

Estas en el tema de DragAndDrop propiedad en el foro de Javascript en Foros del Web. hola a todos... tengo una duda, a ver si alguien sabe decirme porque: var dragobject={ clase: null, z: 0, x: 0, y: 0, offsetx : ...
  #1 (permalink)  
Antiguo 27/07/2007, 15:45
 
Fecha de Ingreso: marzo-2007
Mensajes: 135
Antigüedad: 17 años, 1 mes
Puntos: 0
DragAndDrop propiedad

hola a todos... tengo una duda, a ver si alguien sabe decirme porque:

var dragobject={
clase: null, z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
//************************************************
initialize:function(){
document.onmousedown=this.drag
document.onmouseup=function(){this.dragapproved=0}
},
//************************************************
drag:function(e){
this.clase = "drag"
var evtobj=window.event? window.event : e
this.targetobj=window.event? event.srcElement : e.target
if (this.targetobj.className==this.clase){
this.dragapproved=1
if (isNaN(parseInt(this.targetobj.style.left))){this. targetobj.style.left=0}
if (isNaN(parseInt(this.targetobj.style.top))){this.t argetobj.style.top=0}
this.offsetx=parseInt(this.targetobj.style.left)
this.offsety=parseInt(this.targetobj.style.top)
this.x=evtobj.clientX
this.y=evtobj.clientY
if (evtobj.preventDefault)
evtobj.preventDefault()
document.onmousemove=dragobject.moveit
}
},
//************************************************
moveit:function(e){

var evtobj=window.event? window.event : e
if (this.dragapproved==1){
this.targetobj.style.left=this.offsetx+evtobj.clie ntX-this.x+"px"
this.targetobj.style.top=this.offsety+evtobj.clien tY-this.y+"px"
return false
}
}
}

dragobject.initialize()
dragobject.setclass("drag")

/***=============

Aqui, en la funcion 'drag' del objeto 'dragobject' puedo definir la variable
this.clase = "drag" que por esta misma funcion es llamada.
Pero si esta variable la defino en la funcion 'initialize' de igual modo
(this.clase = "drag"), en la funcion 'drag' toma this.clase como 'undefined'
Por que es esto?

Muchas gracias.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:23.