This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:edge | |
RUN addgroup -g 1000 node \ | |
&& adduser -u 1000 -G node -s /bin/sh -D node | |
RUN mkdir -p /app | |
# Install required dependencies (with Chromium and Firefox) | |
RUN apk update && \ | |
echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img data-src="path/to/image.png" alt="" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import throttle from 'lodash/throttle'; | |
const images = [...document.querySelectorAll('img')]; | |
let windowHeight = window.innerHeight; | |
// We need to store images' sizes in a WeakMap | |
// to get them later in scroll handler | |
const imagesSizes = new WeakMap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isInViewport = ({ top, height, windowHeight }) => { | |
const scroll = window.scrollY || window.pageYOffset; | |
const boundsTop = top + scroll; | |
const viewport = { | |
top: scroll, | |
bottom: scroll + windowHeight, | |
}; | |
const bounds = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const images = [...document.querySelectorAll('img')]; | |
const onIntersection = (entries, observer) => { | |
entries.forEach(async (entry) => { | |
if (entry.isIntersecting) { | |
try { | |
// We use loadImage method from previous example | |
await loadImage(entry.target.src); | |
} catch (error) { | |
console.error(error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="path/to/image.png" loading="lazy" alt="" width="500" height="350"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const loadImage = (src) => { | |
const img = new Image(); | |
return new Promise((resolve, reject) => { | |
img.onload = () => resolve(src); | |
img.onerror = reject; | |
img.src = src; | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { VRInstance } from 'react-vr-web'; | |
import RCTTorusKnot from '../TorusKnot'; | |
function init(bundle, parent, options) { | |
const vr = new VRInstance(bundle, 'WelcomeToVR', parent, { | |
// Register RCTTorusKnot as 'TorusKnot' custom view | |
customViews: [{ | |
name: 'TorusKnot', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
import createReactClass from 'create-react-class'; | |
import { | |
AppRegistry, | |
asset, | |
Pano, | |
DirectionalLight, | |
View, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as ReactVR from 'react-vr-web'; | |
import * as OVRUI from 'ovrui'; | |
import * as THREE from 'three'; | |
import merge from 'react-vr-web/js/Utils/merge'; | |
class RCTTorusKnot extends ReactVR.RCTBaseView { | |
constructor(guiSys) { | |
super(); | |
this.mesh = null; |
NewerOlder