-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Conrad Chan
authored
Feb 19, 2019
1 parent
66ed344
commit 4d3ecc3
Showing
75 changed files
with
3,285 additions
and
254 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Upgrading Guide | ||
========================= | ||
|
||
Upgrading from 1.x to 2.x | ||
------------------------- | ||
Version 2 includes a breaking change to the DOM structure of the Preview element. | ||
|
||
In version 1, the `.bp-navigate` buttons were siblings with the `.bp` container div | ||
``` | ||
<div class="bp" tabindex="0"> | ||
... | ||
</div> | ||
<button class="bp-btn-plain bp-navigate bp-navigate-left bp-is-hidden"> | ||
... | ||
</button> | ||
<button class="bp-btn-plain bp-navigate bp-navigate-right bp-is-hidden"> | ||
... | ||
</button> | ||
``` | ||
But in version 2, the buttons are now inside a new container div `.bp-content`. | ||
``` | ||
<div class="bp" tabindex="0"> | ||
<div class="bp-content"> | ||
<button class="bp-btn-plain bp-navigate bp-navigate-left bp-is-hidden"> | ||
... | ||
</button> | ||
<button class="bp-btn-plain bp-navigate bp-navigate-right bp-is-hidden"> | ||
... | ||
</button> | ||
</div> | ||
</div> | ||
``` | ||
|
||
`.bp-content` is also the new point in which the various viewers will be dynamically inserted as children, i.e. `.bp-doc`, `.bp-image`, etc... | ||
|
||
This change in structure is to account for the new thumbnails sidebar which will appear to the left of the viewer content. |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import Cache from './Cache'; | ||
|
||
class BoundedCache extends Cache { | ||
/** @property {Array} - Maintains the list of cache keys in order in which they were added to the cache */ | ||
cacheQueue; | ||
|
||
/** @property {number} - The maximum number of entries in the cache */ | ||
maxEntries; | ||
|
||
/** | ||
* [constructor] | ||
* | ||
* @param {number} [maxEntries] - Override the maximum number of cache entries | ||
*/ | ||
constructor(maxEntries) { | ||
super(); | ||
|
||
this.maxEntries = maxEntries || 500; | ||
this.cache = {}; | ||
this.cacheQueue = []; | ||
} | ||
|
||
/** | ||
* Destroys the bounded cache | ||
* | ||
* @return {void} | ||
*/ | ||
destroy() { | ||
this.cache = null; | ||
this.cacheQueue = null; | ||
} | ||
|
||
/** | ||
* Caches a simple object in memory. If the number of cache entries | ||
* then exceeds the maxEntries value, then the earliest key in cacheQueue | ||
* will be removed from the cache. | ||
* | ||
* @param {string} key - The cache key | ||
* @param {*} value - The cache value | ||
* @return {void} | ||
*/ | ||
set(key, value) { | ||
// If this key is not already in the cache, then add it | ||
// to the cacheQueue. This avoids adding the same key to | ||
// the cacheQueue multiple times if the cache entry gets updated | ||
if (!this.inCache(key)) { | ||
this.cacheQueue.push(key); | ||
} | ||
|
||
super.set(key, value); | ||
|
||
// If the cacheQueue exceeds the maxEntries then remove the first | ||
// key from the front of the cacheQueue and unset that entry | ||
// from the cache | ||
if (this.cacheQueue.length > this.maxEntries) { | ||
const deleteKey = this.cacheQueue.shift(); | ||
this.unset(deleteKey); | ||
} | ||
} | ||
} | ||
|
||
export default BoundedCache; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
@import 'navigation'; | ||
@import './Controls'; | ||
@import './ProgressBar'; | ||
@import './VirtualScroller'; |
Oops, something went wrong.