@zambezi/caballo-vivo
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -24,5 +24,12 @@ 'use strict'; | ||
}; | ||
}), (0, _operators.scan)(persistPreviousNavToken, {}), (0, _operators.filter)(shouldScroll), (0, _operators.tap)((0, _log2.default)('Scroll to anchor')), (0, _operators.switchMap)(function (_ref) { | ||
}), (0, _operators.scan)(persistPreviousNavToken, {}), (0, _operators.filter)(shouldScroll), (0, _operators.tap)((0, _log2.default)('Scroll to anchor')), (0, _operators.map)(function (_ref) { | ||
var hash = _ref.hash; | ||
return (0, _rxjs.race)(createImmediateElement$(hash), createEventualElement$(hash), (0, _rxjs.empty)().pipe((0, _operators.delay)(10000), (0, _operators.tap)((0, _log2.default)('Scroll to hash timed out')))); | ||
// selectors over ID are invalid if the ID starts with a number, | ||
// so use an ID-based attribute selector | ||
var id = hash.substring(1); // strip the # symbol to leave just the ID | ||
return '[id="' + id + '"]'; | ||
}), (0, _operators.switchMap)(function (selector) { | ||
return (0, _rxjs.race)(createImmediateElement$(selector), createEventualElement$(selector), (0, _rxjs.empty)().pipe((0, _operators.delay)(10000), (0, _operators.tap)((0, _log2.default)('Scroll to hash timed out')))); | ||
})).subscribe(scrollToElement); | ||
@@ -29,0 +36,0 @@ |
@@ -10,4 +10,10 @@ import { Subject, Observable, race, empty } from 'rxjs'; | ||
navToken: state.getIn(['location', 'state', 'navToken'], null) | ||
})), scan(persistPreviousNavToken, {}), filter(shouldScroll), tap(log('Scroll to anchor')), switchMap(({ hash }) => race(createImmediateElement$(hash), createEventualElement$(hash), empty().pipe(delay(10000), tap(log('Scroll to hash timed out')))))).subscribe(scrollToElement); | ||
})), scan(persistPreviousNavToken, {}), filter(shouldScroll), tap(log('Scroll to anchor')), map(({ hash }) => { | ||
// selectors over ID are invalid if the ID starts with a number, | ||
// so use an ID-based attribute selector | ||
const id = hash.substring(1); // strip the # symbol to leave just the ID | ||
return `[id="${id}"]`; | ||
}), switchMap(selector => race(createImmediateElement$(selector), createEventualElement$(selector), empty().pipe(delay(10000), tap(log('Scroll to hash timed out')))))).subscribe(scrollToElement); | ||
export default scrollToAnchor$; | ||
@@ -14,0 +20,0 @@ |
@@ -12,5 +12,12 @@ import { Subject, Observable, race, empty } from 'rxjs'; | ||
}; | ||
}), scan(persistPreviousNavToken, {}), filter(shouldScroll), tap(log('Scroll to anchor')), switchMap(function (_ref) { | ||
}), scan(persistPreviousNavToken, {}), filter(shouldScroll), tap(log('Scroll to anchor')), map(function (_ref) { | ||
var hash = _ref.hash; | ||
return race(createImmediateElement$(hash), createEventualElement$(hash), empty().pipe(delay(10000), tap(log('Scroll to hash timed out')))); | ||
// selectors over ID are invalid if the ID starts with a number, | ||
// so use an ID-based attribute selector | ||
var id = hash.substring(1); // strip the # symbol to leave just the ID | ||
return '[id="' + id + '"]'; | ||
}), switchMap(function (selector) { | ||
return race(createImmediateElement$(selector), createEventualElement$(selector), empty().pipe(delay(10000), tap(log('Scroll to hash timed out')))); | ||
})).subscribe(scrollToElement); | ||
@@ -17,0 +24,0 @@ |
{ | ||
"name": "@zambezi/caballo-vivo", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Caballo Vivo", | ||
@@ -5,0 +5,0 @@ "main": "./lib-commonjs", |
@@ -16,6 +16,13 @@ import { Subject, Observable, race, empty } from 'rxjs' | ||
tap(log('Scroll to anchor')), | ||
switchMap(({ hash }) => | ||
map(({hash}) => { | ||
// selectors over ID are invalid if the ID starts with a number, | ||
// so use an ID-based attribute selector | ||
const id = hash.substring(1) // strip the # symbol to leave just the ID | ||
return `[id="${id}"]` | ||
}), | ||
switchMap(selector => | ||
race( | ||
createImmediateElement$(hash), | ||
createEventualElement$(hash), | ||
createImmediateElement$(selector), | ||
createEventualElement$(selector), | ||
empty().pipe( | ||
@@ -22,0 +29,0 @@ delay(10000), |
56079
1390