473,760 Members | 10,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="RoamImageDi v">
<img id="RoamDynamic Image" src="...">
</div>

Here's the CSS: -

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

#RoamDynamicIma ge
{
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 2286

pe*********@glo balgraphics.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*********@glo balgraphics.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 programmaticall y and see if it still works.

Aug 21 '06 #3

pe*********@glo balgraphics.com wrote:
marss wrote:
pe*********@glo balgraphics.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 programmaticall y 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
6522
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, System.Windows.Forms.PaintEventArgs e) { Graphics g=e.Graphics;
15
31808
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 help. Regards
3
5008
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 I tried skipping base.WndProc alltogether, but it seems like the Menu and Toolbar is part of the non client region and painted during WM_NCPAINT and thus won't show up if base.WndProc is left out. How do I modify the current clip region so...
2
6615
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 to the visible bounds of my control. Obviously, the client rect is simple enough to retrieve, but what I need to do is to clip the line segment to only that portion of the control that is visible, which may _not_ correspond to the client rect...
1
4120
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 for the PictureBox. But it's not working. Here's the code I've written: public void InitializeLinearGradients() { this.Paint += new PaintEventHandler(PaintClient); this.SizeChanged += new EventHandler(SizeClient); pictureLogo.Paint += new...
4
2298
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. make a texture brush, then fill region with the brush. It works on three parts of what I am doing but on the third time it seems to be tiling the image. I don't know waht I am doing wrong. Is there a better way to define a region and draw what...
2
2517
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 cropped image from the function. I sort of have this working, but not thoroughly. If I take the output image of this function and draw it on my form it shows the clipped image as transparent as I am wanting it. But if I take that image and...
9
3414
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 viewport onto the images. Then I use javascript to make the two images scroll through the viewport - the second image is just there to fill the gaps when the first scrolls off the screen. They are seamless 360 degree panoramas, so this gives the...
5
5976
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 trying to get the entire image so that it looks like animation. But this doesn't happen with the code below <html> <head> <style type="text/css"> .img1 { position:absolute;
0
9521
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9333
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10107
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9900
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8768
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7324
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5361
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.