473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Move an image within a clip region

In my Web application, a have an image within a DIV. One of the allowed
user gestures is to drag the image with the mouse. When dragging, parts
of the image that would otherwise be displayed outside the DIV should
be clipped.

I had no trouble at all achieving this on FireFox and Safari. But I
can't get Internet Explorer to do the clipping; it always shows the
whole image, including the bits outside the DIV.

Here's the HTML: -

<div id="RoamImageDiv">
<img id="RoamDynamicImage" src="...">
</div>

Here's the CSS: -

#RoamImageDiv
{
text-align: center ;
vertical-align: middle ;
padding: 0px ;
margin: 0px ;
border: 0px ;
overflow: hidden ;
}

#RoamDynamicImage
{
cursor: default ;
position: relative ;
}

The JavaScript code handling mouse events simple adjusts the
"style.left" and "style.top" of the image element, to make the image
move as the mouse is dragged. This works on all the browsers (except
the clipping thing on IE, of course).

It is my understanding that the situation might be better if I used
"absolute" positioning. However, the position is not really fixed, so
"absolute" would be very difficult, if not impossible, to use in this
situation. I did try dynamically switching to "absolute", after letting
the browser do the layout with "relative", but this totally confused
all the browsers!

Any suggestions?

Aug 21 '06 #1
3 2268

pe*********@globalgraphics.com написав:
I had no trouble at all achieving this on FireFox and Safari. But I
can't get Internet Explorer to do the clipping; it always shows the
whole image, including the bits outside the DIV.

Specify DIV size

#RoamImageDiv
{
....
height:150px;
width:50px;

}

Aug 21 '06 #2

marss wrote:
pe*********@globalgraphics.com написав:
I had no trouble at all achieving this on FireFox and Safari. But I
can't get Internet Explorer to do the clipping; it always shows the
whole image, including the bits outside the DIV.


Specify DIV size

#RoamImageDiv
{
...
height:150px;
width:50px;

}
Thanks.

I have only tried it with the height and width hard-coded in the CSS,
like you have shown. That works, but I cannot actually do it that way
for real, because the size varies. I will now try setting height and
width programmatically and see if it still works.

Aug 21 '06 #3

pe*********@globalgraphics.com wrote:
marss wrote:
pe*********@globalgraphics.com написав:
I had no trouble at all achieving this on FireFox and Safari. But I
can't get Internet Explorer to do the clipping; it always shows the
whole image, including the bits outside the DIV.

Specify DIV size

#RoamImageDiv
{
...
height:150px;
width:50px;

}

Thanks.

I have only tried it with the height and width hard-coded in the CSS,
like you have shown. That works, but I cannot actually do it that way
for real, because the size varies. I will now try setting height and
width programmatically and see if it still works.
Yep, works perfectly. Thanks!

Aug 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: delong | last post by:
Hi I am trying to display a large image on the form and make the form scrollable. My image is about 4200 x 7000 pixel. private void Form1_Paint(object sender,...
15
by: Anand Ganesh | last post by:
HI All, I have an Image. I want to clip a portion of it and copy to another image. How to do this? I know the bounding rectangle to clip. Any suggestions please. Thanks for your time and...
3
by: Martin | last post by:
I'm trying to paint my own caption bar/title bar and also my own frame border, but I'm having problems with modifying the clip region so windows doesn't paint over my stuff when I call base.WndProc...
2
by: Julie | last post by:
How do you retrieve the visible clipping region for a control? I have a control where I do some on-screen drawing (specifically ControlPaint.DrawReversibleLine()), however I need to clip the line...
1
by: Robert W. | last post by:
In my Winforms app I'm trying to get an image's background to appear transparent on a form that has a gradient background. So I added a PictureBox and then attempted to add a custom paint command...
4
by: SStory | last post by:
I am trying very hard to take an image and fill a shape with part of it. The way I do it is get a rectangle for the basic shape, add to a region, make some other shapes and exclude form region....
2
by: Mark Denardo | last post by:
Hi, I need some expert GDI+ person to help me with my RoundOffImage Function: What I'm trying to do is take in an image, crop off the edges around an ellipse region I set up, and then return the...
9
by: Andy Baxter | last post by:
hello, I'm writing a panoramic image viewer in html / javascript. The idea is I have a div with two identical panoramic photographs embedded in it. The clipping on the div is set to make it a...
5
cameokid
by: cameokid | last post by:
Can someone help me out with this. Here is what i am trying to do. I have an image of size 310x310. Initially i am displaying only 50x50 using clip property. Later using setTimeout property i am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.