mirror of
https://github.com/wassname/template.git
synced 2026-07-09 12:52:27 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 399e832441 | |||
| e18d011fa8 |
@@ -42,7 +42,7 @@
|
|||||||
</d-front-matter>
|
</d-front-matter>
|
||||||
<d-title>
|
<d-title>
|
||||||
<figure style="grid-column: page; margin: 1rem 0;"><img src="momentum.png" style="width:100%; border: 1px solid rgba(0, 0, 0, 0.2);"/></figure>
|
<figure style="grid-column: page; margin: 1rem 0;"><img src="momentum.png" style="width:100%; border: 1px solid rgba(0, 0, 0, 0.2);"/></figure>
|
||||||
<p>We often think of Momentum as a means of dampening oscillations and speeding up the iterations, leading to faster convergence. But it has other interesting behavior. It allows a larger range of step-sizes to be used, and creates its own oscillations. What is going on?</p>
|
<p>We often think of Momentum<d-cite key="mercier2011humans"></d-cite> as a means of dampening oscillations and speeding up the iterations, leading to faster convergence. But it has other interesting behavior. It allows a larger range of step-sizes to be used, and creates its own oscillations. What is going on?</p>
|
||||||
</d-title>
|
</d-title>
|
||||||
<d-article>
|
<d-article>
|
||||||
<a class="marker" href="#section-1" id="section-1"><span>1</span></a>
|
<a class="marker" href="#section-1" id="section-1"><span>1</span></a>
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "distill-template",
|
"name": "distill-template",
|
||||||
"version": "2.2.7",
|
"version": "2.2.8",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "distill-template",
|
"name": "distill-template",
|
||||||
"version": "2.2.7",
|
"version": "2.2.8",
|
||||||
"description": "Template for creating Distill articles.",
|
"description": "Template for creating Distill articles.",
|
||||||
"main": "dist/template.v2.js",
|
"main": "dist/template.v2.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
+17
-6
@@ -2,7 +2,7 @@ import { Controller } from './controller';
|
|||||||
|
|
||||||
/* Transforms */
|
/* Transforms */
|
||||||
import { makeStyleTag } from './styles/styles';
|
import { makeStyleTag } from './styles/styles';
|
||||||
import { Polyfills, polyfills } from './helpers/polyfills';
|
import { Polyfills } from './helpers/polyfills';
|
||||||
|
|
||||||
/* Components */
|
/* Components */
|
||||||
import { Abstract } from './components/d-abstract';
|
import { Abstract } from './components/d-abstract';
|
||||||
@@ -48,7 +48,7 @@ const distillMain = function() {
|
|||||||
makeStyleTag(document);
|
makeStyleTag(document);
|
||||||
console.info('Runlevel 1: Static Distill styles have been added.');
|
console.info('Runlevel 1: Static Distill styles have been added.');
|
||||||
console.info('Runlevel 1->2.');
|
console.info('Runlevel 1->2.');
|
||||||
window.distillRunlevel = 2;
|
window.distillRunlevel += 1;
|
||||||
|
|
||||||
/* 3. Register components */
|
/* 3. Register components */
|
||||||
/* Article will register controller which takes control from there */
|
/* Article will register controller which takes control from there */
|
||||||
@@ -73,10 +73,21 @@ const distillMain = function() {
|
|||||||
|
|
||||||
console.info('Runlevel 2: Distill Template finished registering custom elements.');
|
console.info('Runlevel 2: Distill Template finished registering custom elements.');
|
||||||
console.info('Runlevel 2->3.');
|
console.info('Runlevel 2->3.');
|
||||||
window.distillRunlevel = 3;
|
window.distillRunlevel += 1;
|
||||||
console.info('Distill Template initialisation complete.');
|
|
||||||
Controller.listeners.DOMContentLoaded();
|
|
||||||
|
|
||||||
|
/* 4. Register Controller listener functions */
|
||||||
|
for (const [functionName, callback] of Object.entries(Controller.listeners)) {
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
document.addEventListener(functionName, callback);
|
||||||
|
} else {
|
||||||
|
console.error('Runlevel 3: Controller listeners need to be functions!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.info('Runlevel 3: We can now listen to controller events.');
|
||||||
|
console.info('Runlevel 3->4.');
|
||||||
|
window.distillRunlevel += 1;
|
||||||
|
|
||||||
|
console.info('Runlevel 4: Distill Template initialisation complete.');
|
||||||
};
|
};
|
||||||
|
|
||||||
window.distillRunlevel = 0;
|
window.distillRunlevel = 0;
|
||||||
@@ -84,7 +95,7 @@ window.distillRunlevel = 0;
|
|||||||
if (Polyfills.browserSupportsAllFeatures()) {
|
if (Polyfills.browserSupportsAllFeatures()) {
|
||||||
console.info('Runlevel 0: No need for polyfills.');
|
console.info('Runlevel 0: No need for polyfills.');
|
||||||
console.info('Runlevel 0->1.');
|
console.info('Runlevel 0->1.');
|
||||||
window.distillRunlevel = 1;
|
window.distillRunlevel += 1;
|
||||||
distillMain();
|
distillMain();
|
||||||
} else {
|
} else {
|
||||||
console.info('Runlevel 0: Distill Template is loading polyfills.');
|
console.info('Runlevel 0: Distill Template is loading polyfills.');
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// import { Template } from '../mixins/template';
|
// import { Template } from '../mixins/template';
|
||||||
import { Controller } from '../controller';
|
// import { Controller } from '../controller';
|
||||||
|
|
||||||
const isOnlyWhitespace = /^\s*$/;
|
const isOnlyWhitespace = /^\s*$/;
|
||||||
|
|
||||||
@@ -29,20 +29,4 @@ export class Article extends HTMLElement {
|
|||||||
}).observe(this, {childList: true});
|
}).observe(this, {childList: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
|
||||||
document.onreadystatechange = function () {
|
|
||||||
console.log('onreadystatechange:');
|
|
||||||
console.log(document.readyState);
|
|
||||||
};
|
|
||||||
console.info('Article tag connected, we can now listen to controller events.');
|
|
||||||
console.info('Runlevel 3->4.');
|
|
||||||
for (const [functionName, callback] of Object.entries(Controller.listeners)) {
|
|
||||||
if (typeof callback === 'function') {
|
|
||||||
document.addEventListener(functionName, callback);
|
|
||||||
} else {
|
|
||||||
console.error('Controller listeners need to be functions!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export class HoverBox extends T(HTMLElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
listen(element) {
|
listen(element) {
|
||||||
console.log(element)
|
// console.log(element)
|
||||||
this.bindDivEvents(this);
|
this.bindDivEvents(this);
|
||||||
this.bindTriggerEvents(element);
|
this.bindTriggerEvents(element);
|
||||||
// this.style.display = "block";
|
// this.style.display = "block";
|
||||||
|
|||||||
+8
-4
@@ -6,6 +6,10 @@ import optionalComponents from './transforms/optional-components';
|
|||||||
|
|
||||||
const frontMatter = new FrontMatter();
|
const frontMatter = new FrontMatter();
|
||||||
|
|
||||||
|
function domContentLoaded() {
|
||||||
|
return ['interactive', 'complete'].indexOf(document.readyState) !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
export const Controller = {
|
export const Controller = {
|
||||||
|
|
||||||
frontMatter: frontMatter,
|
frontMatter: frontMatter,
|
||||||
@@ -120,7 +124,7 @@ export const Controller = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const prerendered = document.body.hasAttribute('distill-prerendered');
|
const prerendered = document.body.hasAttribute('distill-prerendered');
|
||||||
if (!prerendered) {
|
if (!prerendered && domContentLoaded()) {
|
||||||
optionalComponents(document, frontMatter);
|
optionalComponents(document, frontMatter);
|
||||||
|
|
||||||
const appendix = document.querySelector('distill-appendix');
|
const appendix = document.querySelector('distill-appendix');
|
||||||
@@ -141,18 +145,18 @@ export const Controller = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
DOMContentLoaded() {
|
DOMContentLoaded() {
|
||||||
if (Controller.loaded || ['interactive', 'complete'].indexOf(document.readyState) === -1) {
|
if (Controller.loaded || !domContentLoaded()) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Controller.loaded = true;
|
Controller.loaded = true;
|
||||||
console.log('Controller running DOMContentLoaded');
|
console.log('Runlevel 4: Controller running DOMContentLoaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
const frontMatterTag = document.querySelector('d-front-matter');
|
const frontMatterTag = document.querySelector('d-front-matter');
|
||||||
const data = parseFrontmatter(frontMatterTag);
|
const data = parseFrontmatter(frontMatterTag);
|
||||||
Controller.listeners.onFrontMatterChanged({detail: data});
|
Controller.listeners.onFrontMatterChanged({detail: data});
|
||||||
|
|
||||||
// console.debug('Resolving "citations" dependency due to initial DOM load.');
|
// Resolving "citations" dependency due to initial DOM load
|
||||||
frontMatter.citations = collect_citations();
|
frontMatter.citations = collect_citations();
|
||||||
frontMatter.citationsCollected = true;
|
frontMatter.citationsCollected = true;
|
||||||
for (const waitingCallback of Controller.waitingOn.citations.slice()) {
|
for (const waitingCallback of Controller.waitingOn.citations.slice()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user