TechQA.

Moving div around the page, it gets deformed on screen edge

377 views Asked by AndreaBogazzi At 2013-08-20T16:44:21+00:00 20 August 2013 at 16:44 2025-12-20T23:53:50+00:00

I have some popups whit this structure:

<div id="pop_cont" class="popup_cont" >
    <div id="pop" class="popup" >
        <div class="xclose" ><img src="images/divclose.png" onclick="closediv('pop_cont');" title="chiudimi" /></div>
        <div id="pop_title" class="popup_title" >TITLE</div>
        <div id="pop_int" >SOME CONTENT</div>
    </div>
</div>

with this css:

#alert_cont, .alert_cont, .popup_cont {
    z-index:600;
    position:fixed;
    top:0px;
    left:0px;
    width:100%;
    height:100%;
    background-color:rgba(0,0,0,0.5);
    display: none;
}

#alert, .alert, .popup{
    position: absolute;
    background-color: white;
    border: 1px solid black;
    border-collapse: collapse;
}

#alert_int, .alert_int, .popup_int{
    padding:10px;
}

.xclose {
    right: 1px;
    top: 1px;
    float: right;
    cursor:pointer;
    border:0px; 
}

#alert_title, .alert_title, .popup_title{
    background-color:#ffd600;
    border:1px solid #ffe666;
    color: #000000;
    font-weight: bold;
    font-family: Arial, Helvetica, sans-serif;
    text-align:center;
    cursor: move;
}

I later move the popup i get , grabbing the "class='popup_title'" divs and moving around the parent element. Using this kind of script:

var oDrag = null
var x,y,dx,dy

function mdown(e) {
    if (!e) var e = window.event;
    oDrag = (e.target) ? e.target : e.srcElement
    if (oDrag.className=='popup_title'){
        oDrag=oDrag.parentElement;
        x = e.clientX;
        y = e.clientY;
        dx = x - parseInt(oDrag.style.left);
        dy = y - parseInt(oDrag.style.top);
        document.onmousemove=mdrag_on;
        document.onmouseup=mdrag_off;
    } else {
        oDrag = null;
    }
}

function mdrag_on(e) {
    if (!e) var e = window.event;
    oDrag.style.left = parseInt(e.clientX - dx)+'px';
    oDrag.style.top =parseInt(e.clientY - dy)+'px';
    return false
}

function mdrag_off(e) {
    document.onmousemove=null;
}

Very simple but it works. The problem is that when i get near the edge of the screen, right edge, the div get i'm moving get compressed instead of going offscreen. It get compressed till is possible , wrapping text , when not possible anymore it goes offscreen. When i go back it goes to is standard dimension as soon as possible. There is any method to avoid this? like setting some css of the div i'm moving?

html off-screen
Original Q&A
1

There are 1 answers

0
AndreaBogazzi AndreaBogazzi On 2013-08-21T12:23:50+00:00 21 August 2013 at 12:23

Ok i solved. Or really i didn't solve but i found design error and sort of solution. I have a container that basically is the big shadow that cover everything when the popup comes out. The popup is child of this shadow, so when i go edge of the screen, really i go edge of the shadow and the web browser of course try to make the popup stay inside it. So i gave

width:300%

to my "shadow" container and now it looks fine. ( strange on the left and bottom side it was not happening... )

So now real solution would be to make the shadow not parent to popup, but this would require to have to style.display='block' each time i need to show a popup ( big deal? ) or keep this width:300% Someone as some good suggestion to give me?

Related Questions in HTML

  • How to store a date/time in sqlite (or something similar to a date)
  • How to use custom font during html to pdf conversion?
  • Storing the preferred font-size in localStorage
  • mp4 embedded videos within github pages website not loading
  • Scrimba tutorial was working, suddenly stopped even trying the default
  • Is there any way to glow this bulb image like a real light bulb
  • With non-graphical maps in Leaflet, zoomDelta doesn't work
  • What can I do to improve my coding on both html and css
  • Uncaught TypeError: google.maps.LatLng is not a constructor at init (script.js:7:13)
  • Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
  • Displaying a Movie List on a Website Using Jinja2 and Bootstrap
  • How to redirect to thank you page after submitting a Google form embedded into a Google Site?
  • Storing selected language in localStorage
  • Fences (parenthesis, braces) in HTML and MathML
  • Understanding Scroll Anchoring Behavoir

Related Questions in OFF-SCREEN

  • Take a screenshot of all content (including off-screen) in Flutter
  • How implement an objective-C /swift module to allows an ios application, which sends command to BLE peripheral, execute even in background(offscreen)
  • android viewPager2 turns on offscreenPageLimit
  • Is it possible to make parallel rendering with Vulkan?
  • How to wait layout sistem to determine item's size when exposing QML item to C++?
  • Update an object when an other object is within camera view
  • The way that copy data to a linear tiled image(not using stage buffer)when the format of image is VK_FORMAT_R8G8B8_UNORM seems not work correctly?
  • Get composed frames from Qt WaylandOutput
  • OpenGL rendering & display in different processes
  • Using PDF.js to render to an offscreen canvas
  • Detecting scrolling FPS for UIKit in Swift
  • Onscreen Rendering as well as Offscreen Rendering of electron window
  • How to properly compile ParaView for headless offscreen rendering?
  • How to take action based on detection of locked or off screen in flutter app
  • texture with alpha component rendered offscreen: dots pattern in a multisample renderPass

Popular Questions

  • How do I undo the most recent local commits in Git?
  • How can I remove a specific item from an array in JavaScript?
  • How do I delete a Git branch locally and remotely?
  • Find all files containing a specific text (string) on Linux?
  • How do I revert a Git repository to a previous commit?
  • How do I create an HTML button that acts like a link?
  • How do I check out a remote Git branch?
  • How do I force "git pull" to overwrite local files?
  • How do I list all files of a directory?
  • How to check whether a string contains a substring in JavaScript?
  • How do I redirect to another webpage?
  • How can I iterate over rows in a Pandas DataFrame?
  • How do I convert a String to an int in Java?
  • Does Python have a string 'contains' substring method?
  • How do I check if a string contains a specific word?

Trending Questions

  • UIImageView Frame Doesn't Reflect Constraints
  • Is it possible to use adb commands to click on a view by finding its ID?
  • How to create a new web character symbol recognizable by html/javascript?
  • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
  • Heap Gives Page Fault
  • Connect ffmpeg to Visual Studio 2008
  • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
  • How to avoid default initialization of objects in std::vector?
  • second argument of the command line arguments in a format other than char** argv or char* argv[]
  • How to improve efficiency of algorithm which generates next lexicographic permutation?
  • Navigating to the another actvity app getting crash in android
  • How to read the particular message format in android and store in sqlite database?
  • Resetting inventory status after order is cancelled
  • Efficiently compute powers of X in SSE/AVX
  • Insert into an external database using ajax and php : POST 500 (Internal Server Error)
  • Privacy
  • Terms
  • Cookies
  • Homegardensmart
  • Aftereffectstemplates
  • Jogjafile