I have a function to assess whether an element (an iFrame) is within the viewport if the element is in view it returns true.  function isElementInViewport() {     var el = document.getElementById('postbid_if')     var rect = el.getBoundingCli...
So I am trying to call some functions when fullscreen sections are in the viewport. Let's say I have 7 sections, then I want something to happen when a certain section is inside the viewport (I have a function that snaps the sections into the vie...
I'm performing drawing operations on canvas. The best way to calculate cursor position relative to canvase top left corner is, in my opinion, usage of .getBoundingClientRect():  HTMLCanvasElement.prototype.relativeCoords = function(event) {   var...
I just discovered and really like getBoundingClientRect because it includes sub-pixel precision. This has allowed me to create consistent alignment, even if the user types Ctrl+ or Ctrl+-.  It has properties top, bottom, left, right, & width &...
<body style="width:1000px;height:1000px;">     <div id="d" style="display:inline-block;">         <svg id="s" xmlns="http://www.w3.org/2000/svg" version="1.1" width="200px" height...
When using a range object to getBoundingClientRect in IE11 it reports wrong numbers. It reports the height as 128 while the actual height is 74. It reports the top offset as 8 while the actual top offset is 35.  Is this a known bug? Is there a way to...
I am trying to position a <div> above a users text selection that will act as a toolbar similar to Mediums.    While I have successfully gotten the <div> to be positioned next to the selection, I cannot seem to get it to correctly center...
I have a div with float: right and I'm trying to get its distance from the top of the viewport. In every browser except Safari I'm getting the expected results from element.getBoundingClientRect().top. Safari appears to be reporting the eleme...
I have an array of ClientRect objects which I got by doing  var trackedElements = $('[track]'); var trackedBounds = []; _.each(trackedBounds, function(elem) {     return $(elem)[0].getBoundingClientRect(); });   What I also have is another el...
I am making a script that should measure distances in a post. For example, if i have three posts:   Post 1: two lines of text, then the image that I want to see. Post 2: Just the image that I want to see. Post 3: The image I want to see Followed by t...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.