PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, April 15, 2022

[FIXED] how to move iframe on mouse over using jquery

 April 15, 2022     iframe, javascript, jquery, jquery-events     No comments   

Issue

I am attempting to move an iframe on mouseover in jQuery. I have had some success with this by capturing the mouse position within the iframe, but the flicker off the movement is extreme.

Here is a jsfiddle example

As far as I can see, the reason for the flicker is that every time the iframe moves the x position inside the iframe jumps in the opposite direction, but I can not figure a way of fixing it.


Solution

@charlietf,

Thanks for your efforts, it did indeed lead me in the right direction and I have given a vote to your comment.

The only problem with your example is that as the iframe x position changed the e.pageX changes with it. This means it always equals 0 (or close to).

To get past this I had to add a variable that captures the mouse position within the iframe before any movement has taken place and then remove this number from the x variable when moving the frame.

For anyone out there looking for something similar, here is an update version of charlietf's script with the changes written in. I have also changed from mouseover mouseout events to mousedown mouseup in order to make it easier to play with.

Now I can drag an iframe around from any non active part of my iframe;



Answered By - Finglish
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing