Search completed in 1.16 seconds.
HTMLElement.offsetTop - Web APIs
Working Draft Browser compatibility The compatibility table on this page is generated from structured data. ...
... Working Draft Browser compatibility The compatibility table on this page is generated from structured data. ...
... Working Draft Browser compatibility The compatibility table on this page is generated from structured data. ...
...And 2 more matches
HTMLElement.offsetLeft - Web APIs
The HTMLElement.offsetLeft read-only property returns the number of pixels that the upper left corner of the current element is offset to the left within the HTMLElement.offsetParent node. For block-level elements,
offsetTop, offsetLeft, offsetWidth, and offsetHeight describe the border box of an element relative to the offsetParent. ...
...ad-only property returns the number of pixels that the upper left corner of the current element is offset to the left within the HTMLElement.offsetParent node. For block-level elements,
offsetTop, offsetLeft, offsetWidth, and offsetHeight describe the border box of an element relative to the offsetParent. ...
... Syntax left = element.offsetLeft; left is an integer representing the offset to the left in pixels from the closest relatively positioned parent element. ...
... Working Draft ...
VisualViewport - Web APIs
me>, visual viewport metrics like VisualViewport.width always correspond to layout viewport metrics like document.documentElement.clientWidth. Properties VisualViewport also inherits properties from its parent, EventTarget. VisualViewport.offsetLeft Read only Returns the offset of the left edge of the visual viewport from the left edge of the layout viewport in CSS pixels. VisualViewport.
offsetTop Read only Returns the offset of the top edge of the visual viewport from the top edge of the layout viewport in CSS pixels. VisualViewport.pageLeft Read only Returns the x coordinate of the visual viewport relative to the initial containing block origin of the top edge in CSS pixels. VisualViewport.pageTop Read only Returns the y coordinate of the visual viewport relative to the initial c...
...t. A live sample is also available. var bottomBar = document.getElementById('bottombar'); var viewport = window.visualViewport; function viewportHandler() { var layoutViewport = document.getElementById('layoutViewport'); // Since the bar is position: fixed we need to offset it by the visual // viewport's offset from the layout viewport origin. ...
...sualViewport; function viewportHandler() { var layoutViewport = document.getElementById('layoutViewport'); // Since the bar is position: fixed we need to offset it by the visual // viewport's offset from the layout viewport origin. var offsetLeft = viewport.offsetLeft; var
offsetTop = viewport.height - layoutViewport.getBoundingClientRect().height + viewport.
offsetTop; // You could also do this by setting style.left and style.top if you // use width: 100% instead. ...
... var offsetLeft = viewport.offsetLeft; var
offsetTop = viewport.height - layoutViewport.getBoundingClientRect().height + viewport.
offsetTop; // You could also do this by setting style.left and style.top if you // use width: 100% instead. bottomBar.style.transform = 'translate(' + offsetLeft + 'px,' +
offsetTop + 'px) ' + 'scale(' + 1/viewport.scale + ')' } window.visualViewport.addEventListener('scroll', viewportHandler); window.visualViewport.addEventListener('resize', viewportHandler); Note: This technique should be used with care; emulating position: device-fixed in this way can result in the fixed element flickering during scrolling. Specifications Specif...
Color picker tool - CSS: Cascading Style Sheets
bind(this)); this.node.appendChild(button); }; /*************************************************************************/ // Updates properties of UI elements /*************************************************************************/ ColorPicker.prototype.updateColor = function updateColor(e) { var x = e.pageX - this.picking_area.offsetLeft; var y = e.pageY - this.picking_area.
offsetTop; var picker_offset = 5; // width and height should be the same var size = this.picking_area.clientWidth; if (x > size) x = size; if (y > size) y = size; if (x < 0) x = 0; if (y < 0) y = 0; var value = 100 - (y * 100 / size) | 0; var saturation = x * 100 / size | 0; if (this.picker_mode === 'HSV') this.color.setHSV(this.color.hue, saturation, value); if (this.picker_mo...
... = 1; else if (axis === 'height') action = -1; else axis = 'both'; handle.className = 'resize-handle'; handle.setAttribute('data-resize', axis); handle.addEventListener('mousedown', resizeStart); elem.appendChild(handle); }; /*========== Make an element draggable relative to it's parent ==========*/ var makeDraggable = function makeDraggable(elem, endFunction) { var
offsetTop; var offsetLeft; elem.setAttribute('data-draggable', 'true'); var dragStart = function dragStart(e) { e.preventDefault(); e.stopPropagation(); if (e.target.getAttribute('data-draggable') !== 'true' || e.target !== elem || e.button !== 0) return; offsetLeft = e.clientX - elem.offsetLeft;
offsetTop = e.clientY - elem.
offsetTop; document.addEventListen...
...ve', mouseDrag); document.addEventListener('mouseup', dragEnd); }; var dragEnd = function dragEnd(e) { if (e.button !== 0) return; document.removeEventListener('mousemove', mouseDrag); document.removeEventListener('mouseup', dragEnd); }; var mouseDrag = function mouseDrag(e) { elem.style.left = e.clientX - offsetLeft + 'px'; elem.style.top = e.clientY -
offsetTop + 'px'; }; elem.addEventListener('mousedown', dragStart, false); }; return { makeResizable : makeResizable, makeDraggable : makeDraggable }; })(); /*========== Color Class ==========*/ var Color = UIColorPicker.Color; var HSLColor = UIColorPicker.HSLColor; /** * ColorPalette */ var ColorPalette = (function ColorPalette() { var samples = []; var color_palette...
... null; }; CanvasSample.prototype.updatePosition = function updatePosition(posX, posY) { this.node.style.top = posY - this.startY + 'px'; this.node.style.left = posX - this.startX + 'px'; }; var canvasDropEvent = function canvasDropEvent(e) { var color = Tool.getSampleColorFrom(e); if (color) { var offsetX = e.pageX - canvas.offsetLeft; var offsetY = e.pageY - canvas.
offsetTop; var sample = new CanvasSample(color, offsetX, offsetY); if (tutorial) { tutorial = false; canvas.removeAttribute('data-tutorial'); var info = new CanvasSample(new Color(), 100, 100); info.node.setAttribute('data-tutorial', 'dblclick'); } } }; var setActiveSample = function setActiveSample(sample) { ColorPickerSamples.unsetActiveSample(); Tool.unsetV...
Build the brick field - Game development
a two-dimensional array. First however we need to set up some variables to define information about the bricks such as their width and height, rows and columns, etc. Add the following lines to your code below the variables which you have previously declared in your program. var brickRowCount = 3; var brickColumnCount = 5; var brickWidth = 75; var brickHeight = 20; var brickPadding = 10; var brick
OffsetTop = 30; var brickOffsetLeft = 30; Here we've defined the number of rows and columns of bricks , their width and height, the padding between the bricks so they won't touch each other and a top and left offset so they won't start being drawn right from the edge of the Canvas. We will hold all our bricks in a two-dimensional array. It will contain the brick columns (c), which in turn will contain th...
... brick on the Canvas -- size brickWidth x brickHeight -- with each loop iteration. The problem is that we're painting them all in one place, at coordinates (0,0). What we need to do is include some calculations that will work out the x and y position of each brick for each loop iteration: var brickX = (c*(brickWidth+brickPadding))+brickOffsetLeft; var brickY = (r*(brickHeight+brickPadding))+brick
OffsetTop; Each brickX position is worked out as brickWidth + brickPadding, multiplied by the column number, c, plus the brickOffsetLeft; the logic for the brickY is identical except that it uses the values for row number, r, brickHeight, and brick
OffsetTop. Now every single brick can be placed in its correct place row and column, with padding between each brick, drawn at an offset from the left and top c...
... brickX and brickY values as the coordinates instead of (0,0) each time, will look like this -- add this into your code below the drawPaddle() function: function drawBricks() { for(var c=0; c<brickColumnCount; c++) { for(var r=0; r<brickRowCount; r++) { var brickX = (c*(brickWidth+brickPadding))+brickOffsetLeft; var brickY = (r*(brickHeight+brickPadding))+brick
OffsetTop; bricks[c][r].x = brickX; bricks[c][r].y = brickY; ctx.beginPath(); ctx.rect(brickX, brickY, brickWidth, brickHeight); ctx.fillStyle = "#0095DD"; ctx.fill(); ctx.closePath(); } } } Actually drawing the bricks The last thing to do in this lesson is to add a call to drawBricks() somewhere in the draw()...
Visual Viewport API - Web APIs
{ if (pendingUpdate) return; pendingUpdate = true; requestAnimationFrame(() => { pendingUpdate = false; var layoutViewport = document.getElementById('layoutViewport'); // Since the bar is position: fixed we need to offset it by the // visual viewport's offset from the layout viewport origin. ...
...var layoutViewport = document.getElementById('layoutViewport'); // Since the bar is position: fixed we need to offset it by the // visual viewport's offset from the layout viewport origin. var viewport = event.target; var offsetLeft = viewport.offsetLeft; var
offsetTop = viewport.height - layoutViewport.getBoundingClientRect().height + viewport.
offsetTop; // You could also do this by setting style.left and style.top if you // use width: 100% instead. ...
... = viewport.offsetLeft; var
offsetTop = viewport.height - layoutViewport.getBoundingClientRect().height + viewport.
offsetTop; // You could also do this by setting style.left and style.top if you // use width: 100% instead. bottomBar.style.transform = 'translate(' + offsetLeft + 'px,' +
offsetTop + 'px) ' + 'scale(' + 1/viewport.scale + ')' }) } window.visualViewport.addEventListener('scroll', viewportHandler); window.visualViewport.addEventListener('resize', viewportHandler); Specifications Specification Status Comment Visual Viewport APIThe definition of 'VisualViewport' in that specification. Draft Initial definition.
Border-image generator - CSS: Cascading Style Sheets
bscribe : subscribe, unsubscribe : unsubscribe }; })(); window.addEventListener("load", function() { BorderImage.init(); }); var BorderImage = (function BorderImage() { var getElemById = document.getElementById.bind(document); var subject; var preview; var guidelines = []; var positions = ['top', 'right', 'bottom', 'left']; var makeDraggable = function makeDraggable(elem) { var
offsetTop; var offsetLeft; elem.setAttribute('data-draggable', 'true'); var dragStart = function dragStart(e) { if (e.target.getAttribute('data-draggable') !== 'true' || e.target !== elem || e.button !== 0) return; offsetLeft = e.clientX - elem.offsetLeft;
offsetTop = e.clientY - elem.
offsetTop; document.addEventListener('mousemove', mouseDrag); document.addEventListener('m...
...r('mousemove', mouseDrag); document.addEventListener('mouseup', dragEnd); }; var dragEnd = function dragEnd(e) { if (e.button !== 0) return; document.removeEventListener('mousemove', mouseDrag); document.removeEventListener('mouseup', dragEnd); }; var mouseDrag = function mouseDrag(e) { elem.style.left = e.clientX - offsetLeft + 'px'; elem.style.top = e.clientY -
offsetTop + 'px'; }; elem.addEventListener('mousedown', dragStart, false); }; var PreviewControl = function PreviewControl() { var dragging = false; var valueX = null; var valueY = null; var dragStart = function dragStart(e) { if (e.button !== 0) return; valueX = e.clientX - preview.clientWidth; valueY = e.clientY - preview.clientHeight; dragging = true; document.addE...
... if (unit_topic) InputSliderManager.setStep(unit_topic, value); }; var show = function show(e) { var topic = e.target.getAttribute('data-topic'); var precision = InputSliderManager.getPrecision(topic); var step = InputSliderManager.getStep(topic); unit_topic = topic; title.textContent = topic; panel.setAttribute('data-active', 'true'); panel.style.top = e.target.
offsetTop - 40 + 'px'; panel.style.left = e.target.offsetLeft + 30 + 'px'; InputSliderManager.setValue('unit-precision', precision); InputSliderManager.setValue('unit-step', step); }; var init = function init() { panel = document.createElement('div'); title = document.createElement('div'); var close = document.createElement('div'); step = InputSliderManager.createSlider('unit-st...
Mobile accessibility - Learn web development
specific events such as mousedown and mouseup create problems -- their event handlers cannot be invoked using non-mouse controls. If you try to control our simple-box-drag.html (see example live) example with a keyboard or touch, you'll see the problem. ...
...code such as the following: div.onmousedown = function() { initialBoxX = div.offsetLeft; initialBoxY = div.
offsetTop; movePanel(); } document.onmouseup = stopMove; To enable other forms of control, you need to use different, yet equivalent events -- for example, touch events work on touchscreen devices: div.ontouchstart = function(e) { initialBoxX = div.offsetLeft; initialBoxY = div.
offsetTop; positionHandler(e); movePanel(); } panel.ontouchend = stopMove; We've provided a simple example that shows how to use the mouse and touch events together -- see multi-control-box-drag.html (see the example live also). Note: You can also see fully functional examples showing how to implement different control mechanisms at Implementing game control mechanisms. Responsive design Respons...
HTMLElement - Web APIs
HTMLElement.offsetHeight Read only Returns a double containing the height of an element, relative to the layout. HTMLElement.offsetLeft Read only Returns a double, the distance from this element's left border to its offsetParent's left border. HTMLElement.offsetParent Read only Returns a Element that is the element from which all offset calculations are currently computed. HTMLElement.
offsetTop Read only Returns a double, the distance from this element's top border to its offsetParent's top border. HTMLElement.offsetWidth Read only Returns a double containing the width of an element, relative to the layout. HTMLElement.properties Read only Returns a HTMLPropertiesCollection... HTMLElement.spellcheck Is a Boolean that controls spell-checking. It is present on all HTML elemen...
...lso available via the ontransitionrun property. transitionstart Fired when a CSS transition has actually started. Also available via the ontransitionstart property. Specifications Specification Status Comment CSS Object Model (CSSOM) View ModuleThe definition of 'HTMLElement' in that specification. Working Draft Added the following properties: offsetParent,
offsetTop, offsetLeft, offsetWidth, and offsetHeight. HTML Living StandardThe definition of 'HTMLElement' in that specification. Living Standard Added the following properties: translate, itemScope, itemType, itemId, itemRef, itemProp, properties, and itemValue. Added the following method: forceSpellcheck(). Moved the onXYZ attributes to the GlobalEventHandlers interface and added an...
Index - Web APIs
nt node. 1629 HTMLElement.offsetParent API, CSSOM View, NeedsMarkupWork, Property, Reference The HTMLElement.offsetParent read-only property returns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element. If the element is non-positioned, the nearest td, th, table or the body is returned. 1630 HTMLElement.
offsetTop API, CSSOM View, NeedsMarkupWork, Property, Read-only, Reference The HTMLElement.
offsetTop read-only property returns the distance of the current element relative to the top of the offsetParent node. 1631 HTMLElement.offsetWidth API, CSSOM View, NeedsMarkupWork, Property, Read-only, Reference The HTMLElement.offsetWidth read-only property returns the layout width of...
...object. Each window on a page will have a unique VisualViewport representing the properties associated with that window. 4543 VisualViewport.height API, Property, Reference, Visual Viewport API, VisualViewport, height, viewport The height read-only property of the VisualViewport interface returns the height of the visual viewport, in CSS pixels. 4544 VisualViewport.
offsetTop API, Property, Reference, Visual Viewport API, VisualViewport,
offsetTop, viewport The
offsetTop read-only property of the VisualViewport interface returns the offset of the top edge of the visual viewport from the top edge of the layout viewport in CSS pixels. 4545 VisualViewport.offsetleft API, Property, Reference, Visual Viewport API, VisualViewport, offsetleft, viewpo...
window.location - Web APIs
he current URL with "?Some%20data" appended is sent to the server (if no action is taken by the server, the current document is reloaded with the modified search string). ...
... Living Standard No change from HTML5. HTML5The definition of 'window.location' in that specification. Re...
Window.pageYOffset - Web APIs
ing to scroll, and a <div> into which we'll output the value of pageYOffset when we've finished the scroll. <iframe id="frame"> </iframe> <div id="info"> </div> JavaScript var frame = document.getElementById("frame"); var frameDoc = frame.contentDocument; var info = document.getElementById("info"); var target = frameDoc.getElementById("overview"); frameDoc.scrollingElement.scrollTop = target.
offsetTop; info.innerText = "Y offset after scrolling: " + frame.contentWindow.pageYOffset + " pixels"; The JavaScript code begins by getting into frame and info the <iframe> element that contains our content as well as the <div> element into which we'll output the result of our scroll position check. It then gets a reference to the element we want to scroll into view calling getElementB...
...g into frame and info the <iframe> element that contains our content as well as the <div> element into which we'll output the result of our scroll position check. It then gets a reference to the element we want to scroll into view calling getElementById() on the frame's HTMLIFrameElement.contentDocument. With the target element in hand, we set the scrollTop of the frame's scrollingElement to the
offsetTop of the target element. By doing so, we set the vertical scrolling position of the frame's document so that it's the same as the top edge of the target element. This will automatically set the scrolling position to the maximum possible value if the attempted scroll would exceed the maximum. This prevents us from falling off the edge of the document. Nobody wants to know what's out there. There mi...
Window.screenLeft - Web APIs
les In our screenleft-screentop example, you'll see a canvas onto which has been drawn a circle. In this example we are using screenLeft/screenTop plus Window.requestAnimationFrame() to constantly redraw the circle in the same physical position on the screen, even if the window position is moved. ...
...enTop plus Window.requestAnimationFrame() to constantly redraw the circle in the same physical position on the screen, even if the window position is moved. ...
Window.screenTop - Web APIs
les In our screenleft-screentop example, you'll see a canvas onto which has been drawn a circle. In this example we are using screenLeft/screenTop plus Window.requestAnimationFrame() to constantly redraw the circle in the same physical position on the screen, even if the window position is moved. ...
...enTop plus Window.requestAnimationFrame() to constantly redraw the circle in the same physical position on the screen, even if the window position is moved. ...
Window.screenX - Web APIs
ntop (source code) example, you'll see a canvas onto which has been drawn a circle. In this example we are using Window.screenLeft/Window.screenTop plus Window.requestAnimationFrame() to constantly redraw the circle in the same physical position on the screen, even if the window position is moved. ...
...enTop plus Window.requestAnimationFrame() to constantly redraw the circle in the same physical position on the screen, even if the window position is moved. ...
Window.screenY - Web APIs
reenleft-screentop example, you'll see a canvas onto which has been drawn a circle. In this example we are using Window.screenLeft/Window.screenTop plus Window.requestAnimationFrame() to constantly redraw the circle in the same physical position on the screen, even if the window position is moved. ...
...enTop plus Window.requestAnimationFrame() to constantly redraw the circle in the same physical position on the screen, even if the window position is moved. ...
Cubic Bezier Generator - CSS: Cascading Style Sheets
(); ctx.stroke(); ctx.closePath(); } else { alert('You need Safari or Firefox 1.5+ to see this demo.'); } } function mouseDown(e) { var canvas = document.getElementById('bezier'); var x1 = cX(document.getElementById('x1').value); var y1 = cY(document.getElementById('y1').value); var x = e.pageX - canvas.offsetLeft; var y = e.pageY - canvas.
offsetTop; var output = document.getElementById('output'); output.value = "(" + x + "," + y + ") should be (" + x1 + "," + y1 + ")"; if ((x1 + radius >= x) && (x1 - radius <= x) && (y1 + radius >= y) && (y1 - radius <= y)) { var output = document.getElementById('output'); output.value = "P1!"; dragSM = 1; } var x2 = cX(document.getElementById('x2').value); ...
...gSM != 0) { canvas.onmousemove = mouseMove; } } function mouseUp(e) { var output = document.getElementById('output'); output.value = "Mouse up!"; dragSM = 0; canvas.onmousemove = null; } function mouseMove(e) { if (dragSM != 0) { var canvas = document.getElementById('bezier'); var x = e.pageX - canvas.offsetLeft; var y = e.pageY - canvas.
offsetTop; var output = document.getElementById('output'); output.value = "Drag!"; if (dragSM == 1) { var x1 = document.getElementById('x1'); var y1 = document.getElementById('y1'); x1.value = reverseX(x); x1.value = Math.round(x1.value * 10000) / 10000; y1.value = reverseY(y); y1.value = Math.round(y1.value *...
Forms related code snippets - Archive of obsolete content
pt); this.container.appendChild(oTHead); this.current.setDate(1); this.writeDays(); oTarget.onclick = function () { if (oTable.parentNode) { oTable.parentNode.removeChild(oTable); return; } oTable.style.zIndex = nZIndex++; oTable.style.position = "absolute"; oTable.style.left = oTarget.offsetLeft + "px"; oTable.style.top = (oTarget.
offsetTop + oTarget.offsetHeight) + "px"; oTarget.parentNode.insertBefore(oTable, oTarget); }; aInstances.push(this); } DatePicker.prototype.writeDays = function () { const nEndBlanks = (this.current.getDay() + bZeroIsMonday * 6) % 7, nEnd = aMonthLengths[this.current.getMonth()] + nEndBlanks, nTotal = nEnd + ((7 - nEnd % 7) % 7); var oTD, oTR; ...
jspage - Archive of obsolete content
){if(this.getBoundingClientRect){var j=this.getBoundingClientRect(),m=document.id(this.getDocument().documentElement),p=m.getScroll(),k=this.getScrolls(),i=this.getScroll(),h=(d(this,"position")=="fixed"); return{x:j.left.toInt()+k.x-i.x+((h)?0:p.x)-m.clientLeft,y:j.top.toInt()+k.y-i.y+((h)?0:p.y)-m.clientTop};}var l=this,n={x:0,y:0};if(b(this)){return n; }while(l&&!b(l)){n.x+=l.offsetLeft;n.y+=l.
offsetTop;if(Browser.Engine.gecko){if(!f(l)){n.x+=c(l);n.y+=g(l);}var o=l.parentNode;if(o&&d(o,"overflow")!="visible"){n.x+=c(o); n.y+=g(o);}}else{if(l!=this&&Browser.Engine.webkit){n.x+=c(l);n.y+=g(l);}}l=l.offsetParent;}if(Browser.Engine.gecko&&!f(this)){n.x-=c(this);n.y-=g(this); }return n;},getPosition:function(k){if(b(this)){return{x:0,y:0};}var l=this.getOffsets(),i=this.getScrolls();var h={x:l.x-i.x...
Mobile touch controls - Game development
We can get the first touch (e.touches[0], our example is not multitouch-enabled), extract the pageX and pageY variables and set the player's ship position on th...
CanvasRenderingContext2D.drawFocusIfNeeded() - Web APIs
redraw, true); document.addEventListener('blur', redraw, true); canvas.addEventListener('click', handleClick, false); redraw(); function redraw() { ctx.clearRect(0, 0, canvas.width, canvas.height); drawButton(button1, 20, 20); drawButton(button2, 20, 80); } function handleClick(e) { // Calculate click coordinates const x = e.clientX - canvas.offsetLeft; const y = e.clientY - canvas.
offsetTop; // Focus button1, if appropriate drawButton(button1, 20, 20); if (ctx.isPointInPath(x, y)) { button1.focus(); } // Focus button2, if appropriate drawButton(button2, 20, 80); if (ctx.isPointInPath(x, y)) { button2.focus(); } } function drawButton(el, x, y) { const active = document.activeElement === el; const width = 150; const height = 40; // Button background...
Element.clientTop - Web APIs
The width of the top border of an element in pixels. It is a read-only, integer property of element. As it happens, all that lies between the two locations (
offsetTop and client area top) is the element's border. This is because the
offsetTop indicates the location of the top of the border (not the margin) while the client area starts immediately below the border, (client area includes padding.) Therefore, the clientTop value will always equal the integer portion of the .getComputedStyle() value for "border-top-width". (Actually might be Math.round(parseFloat()).) For example, if the computed "border-top-width" is zero, then clientTop is also zero. Note: This property will round the value to an integer. If you need a fractional value, use element.getBoundingClientRect(). Gecko-based applicati...
HTMLElement.offsetParent - Web APIs
the nearest ancestor td, th, table will be returned, or the body if there are no ancestor table elements either. NOTE: offsetParent returns null in the following situations: The element or its parent element has the display property set to none. The element has the position property set to fixed (firefox returns <body>). The element is <body> or <html>. offsetParent is useful because
offsetTop and offsetLeft are relative to its padding edge. Syntax parentObj = element.offsetParent; parentObj is an object reference to the element in which the current element is offset. Specification Specification Status Comment CSS Object Model (CSSOM) View ModuleThe definition of 'offsetParent' in that specification. Working Draft Browser compatibility...
Raining rectangles - Web APIs
playerClick (evt) { // We need to transform the position of the click event from // window coordinates to relative position inside the canvas. // In addition we need to remember that vertical position in // WebGL increases from bottom to top, unlike in the browser // window. var position = [ evt.pageX - evt.target.offsetLeft, gl.drawingBufferHeight - (evt.pageY - evt.target.
offsetTop), ]; // if the click falls inside the rectangle, we caught it. // Increment score and create a new rectangle. var diffPos = [ position[0] - rainingRect.position[0], position[1] - rainingRect.position[1] ]; if ( diffPos[0] >= 0 && diffPos[0] < rainingRect.size[0] && diffPos[1] >= 0 && diffPos[1] < rainingRect.size[1] ) { score += 1; scoreDisplay.innerHTML = score; ...
Box-shadow generator - CSS: Cascading Style Sheets
olorpicker; var hue_area; var gradient_area; var alpha_area; var gradient_picker; var hue_selector; var alpha_selector; var pick_object; var info_rgb; var info_hsv; var info_hexa; var output_color; var color = new Color(); var subscribers = []; var updateColor = function updateColor(e) { var x = e.pageX - gradient_area.offsetLeft; var y = e.pageY - gradient_area.
offsetTop; // width and height should be the same var size = gradient_area.clientWidth; if (x > size) x = size; if (y > size) y = size; if (x < 0) x = 0; if (y < 0) y = 0; var value = 100 - (y * 100 / size) | 0; var saturation = x * 100 / size | 0; color.setHSV(color.hue, saturation, value); // should update just // color pointer location updateUI(); noti...
Linear-gradient Generator - CSS: Cascading Style Sheets
bind(this)); this.node.appendChild(button); }; /*************************************************************************/ // Updates properties of UI elements /*************************************************************************/ ColorPicker.prototype.updateColor = function updateColor(e) { var x = e.pageX - this.picking_area.offsetLeft; var y = e.pageY - this.picking_area.
offsetTop; // width and height should be the same var size = this.picking_area.clientWidth; if (x > size) x = size; if (y > size) y = size; if (x < 0) x = 0; if (y < 0) y = 0; var value = 100 - (y * 100 / size) | 0; var saturation = x * 100 / size | 0; if (this.picker_mode === 'HSV') this.color.setHSV(this.color.hue, saturation, value); if (this.picker_mode === 'HSL') this.col...
for - JavaScript
ng for cycle calculates the offset position of a node in the final-expression section, and therefore it does not require the use of a statement section, a semicolon is used instead. ...