Skip to content

Instantly share code, notes, and snippets.

View michalkvasnicak's full-sized avatar
🏠
Working from home

Michal Kvasničák michalkvasnicak

🏠
Working from home
View GitHub Profile
@michalkvasnicak
michalkvasnicak / index.js
Created August 24, 2017 15:27
styled-components 2 and flow 0.53.1
// @flow
type ComponentListType = $Subtype<$Keys<$npm$styledComponents$StyledComponentsComponentList>>
type $npm$styledComponents$Interpolation = ((executionContext: Object) => string) | string | number;
type $npm$styledComponents$NameGenerator = (hash: number) => string;
type $npm$styledComponents$TaggedTemplateLiteral<R> = {| (Array<string>, $npm$styledComponents$Interpolation): R |};
type $npm$styledComponents$ReactComponentFunctional<Props: {}> = React$StatelessFunctionalComponent<Props>
@michalkvasnicak
michalkvasnicak / angular-better-image-lazy-load.js
Last active December 2, 2019 23:19
Better image lazy loading in AngularJS
angular.module('Demo', []).service(
'scrollAndResizeListener', function($window, $document, $timeout) {
var id = 0,
listeners = {},
scrollTimeoutId,
resizeTimeoutId;
function invokeListeners() {
var clientHeight = $document[0].documentElement.clientHeight,
clientWidth = $document[0].documentElement.clientWidth;
@michalkvasnicak
michalkvasnicak / angular-naive-image-lazy-load.js
Last active August 29, 2015 14:04
Naive image lazy loading in AngularJS
angular.module('Demo', []).directive(
'imageLazySrc', function($document, $window) {
return {
restrict: 'A',
link: function($scope, $element, $attributes) {
function isInView() {
// get current viewport position and dimensions, and image position
var clientHeight = $document[0].documentElement.clientHeight,
clientWidth = $document[0].documentElement.clientWidth,