Compare commits
No commits in common. "912c2d746e96236368cc18e0a69d7d0bdb770938" and "7d4abed595f1d89f01cf97a36136898d55eb9327" have entirely different histories.
912c2d746e
...
7d4abed595
6 changed files with 26 additions and 92 deletions
BIN
IMFePIit29P.ttf
BIN
IMFePIit29P.ttf
Binary file not shown.
BIN
IMFePIsc29P.ttf
BIN
IMFePIsc29P.ttf
Binary file not shown.
BIN
img/gretchen.jpg
BIN
img/gretchen.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 786 KiB |
|
|
@ -35,8 +35,8 @@ export class Display {
|
||||||
target.addEventListener('drop', e => {
|
target.addEventListener('drop', e => {
|
||||||
let target = findA(e.target)
|
let target = findA(e.target)
|
||||||
if (!target || !target.draggable) return
|
if (!target || !target.draggable) return
|
||||||
|
e.preventDefault()
|
||||||
dispatch({ action: 'link', from: e.dataTransfer.getData("application/prs.x"), to: target.dataset['id']})
|
dispatch({ action: 'link', from: e.dataTransfer.getData("application/prs.x"), to: target.dataset['id']})
|
||||||
&& e.preventDefault()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.graph = new Springy.Graph()
|
this.graph = new Springy.Graph()
|
||||||
|
|
@ -58,9 +58,7 @@ export class Display {
|
||||||
graph.addNode(new Springy.Node(item.id, item))
|
graph.addNode(new Springy.Node(item.id, item))
|
||||||
}
|
}
|
||||||
for (const item of state.links) {
|
for (const item of state.links) {
|
||||||
graph.addEdge(new Springy.Edge(item.id, graph.nodeSet[item.from], graph.nodeSet[item.to], {
|
graph.addEdge(new Springy.Edge(item.id, graph.nodeSet[item.from], graph.nodeSet[item.to], {}))
|
||||||
text: state.items[item.from].linkable.filter(i => state.items[item.to].linkable.includes(i)).join(', ')
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
let currentBB = this.layout.getBoundingBox()
|
let currentBB = this.layout.getBoundingBox()
|
||||||
let width = this.target.scrollWidth || 100
|
let width = this.target.scrollWidth || 100
|
||||||
|
|
@ -72,6 +70,12 @@ export class Display {
|
||||||
return new Springy.Vector(sx, sy);
|
return new Springy.Vector(sx, sy);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var fromScreen = function(s) {
|
||||||
|
var size = currentBB.topright.subtract(currentBB.bottomleft);
|
||||||
|
var px = (s.x / canvas.width) * size.x + currentBB.bottomleft.x;
|
||||||
|
var py = (s.y / canvas.height) * size.y + currentBB.bottomleft.y;
|
||||||
|
return new Springy.Vector(px, py);
|
||||||
|
};
|
||||||
var renderer = new Springy.Renderer(
|
var renderer = new Springy.Renderer(
|
||||||
this.layout,
|
this.layout,
|
||||||
() => {
|
() => {
|
||||||
|
|
@ -82,7 +86,7 @@ export class Display {
|
||||||
},
|
},
|
||||||
function drawEdge(edge, p1, p2) {
|
function drawEdge(edge, p1, p2) {
|
||||||
const dom = document.createElement('span')
|
const dom = document.createElement('span')
|
||||||
dom.innerText = edge.data.text
|
dom.innerText = 'text'
|
||||||
p1 = toScreen(p1)
|
p1 = toScreen(p1)
|
||||||
p2 = toScreen(p2)
|
p2 = toScreen(p2)
|
||||||
if (p1.y > p2.y) [p1, p2] = [p2, p1]
|
if (p1.y > p2.y) [p1, p2] = [p2, p1]
|
||||||
|
|
@ -92,17 +96,22 @@ export class Display {
|
||||||
let rad = Math.atan(b / a)
|
let rad = Math.atan(b / a)
|
||||||
if (negative) rad = rad + Math.PI
|
if (negative) rad = rad + Math.PI
|
||||||
if (rad > Math.PI / 2) {
|
if (rad > Math.PI / 2) {
|
||||||
|
console.warn(negative)
|
||||||
rad += Math.PI
|
rad += Math.PI
|
||||||
;[p2, p1] = [p1, p2]
|
;[p2, p1] = [p1, p2]
|
||||||
}
|
} else if (negative) { console.warn(false) }
|
||||||
|
|
||||||
dom.className = 'line'
|
dom.style.transformOrigin = '0 0'
|
||||||
dom.style.transform = 'rotate(' + rad + 'rad) translateY(-1em)'
|
dom.style.transform = 'rotate(' + rad + 'rad) translateY(-1em)'
|
||||||
|
dom.style.position = 'absolute'
|
||||||
dom.style.left = p1.x + 'px'
|
dom.style.left = p1.x + 'px'
|
||||||
dom.style.top = p1.y + 'px'
|
dom.style.top = p1.y + 'px'
|
||||||
dom.style.right = p2.x + 'px'
|
dom.style.right = p2.x + 'px'
|
||||||
dom.style.bottom = p2.y + 'px'
|
dom.style.bottom = p2.y + 'px'
|
||||||
dom.style.width = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)) + 'px'
|
dom.style.width = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)) + 'px'
|
||||||
|
dom.style.height = '1em'
|
||||||
|
dom.style.borderBottom = '3px solid black'
|
||||||
|
dom.style.textAlign = 'center'
|
||||||
// FIXME eigentlich falsches parent
|
// FIXME eigentlich falsches parent
|
||||||
field.appendChild(dom)
|
field.appendChild(dom)
|
||||||
},
|
},
|
||||||
|
|
@ -136,18 +145,8 @@ export class Display {
|
||||||
if (state.show !== null) {
|
if (state.show !== null) {
|
||||||
const wrapper = document.createElement('a')
|
const wrapper = document.createElement('a')
|
||||||
wrapper.href = '/'
|
wrapper.href = '/'
|
||||||
wrapper.className = 'fullview'
|
|
||||||
const fullview = document.createElement('div')
|
const fullview = document.createElement('div')
|
||||||
const name = 'Gretchen'
|
wrapper.className = 'fullview'
|
||||||
const desc = 'Näherin, 20'
|
|
||||||
const img = '/img/gretchen.jpg'
|
|
||||||
const text = '<p>Text</p><p>More text text text</p>'
|
|
||||||
fullview.innerHTML = `
|
|
||||||
<img src=${img} />
|
|
||||||
<h1>${name}</h1>
|
|
||||||
<p class=desc>${desc}</p>
|
|
||||||
<div class=fulltext>Text text</div>
|
|
||||||
`
|
|
||||||
wrapper.appendChild(fullview)
|
wrapper.appendChild(fullview)
|
||||||
target.appendChild(wrapper)
|
target.appendChild(wrapper)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
19
src/index.js
19
src/index.js
|
|
@ -4,15 +4,9 @@ const target = document.createElement('div')
|
||||||
|
|
||||||
const state = {items: [], show: null, links: [] }
|
const state = {items: [], show: null, links: [] }
|
||||||
|
|
||||||
const items = [
|
const imgs = ['Dienstmädchen2.svg', 'Rucksack2.svg', 'Theater2.svg', 'UnskilledLabour2.svg', 'weben.svg']
|
||||||
{img: 'Dienstmädchen2.svg', linkable: ['Prekär']},
|
for (let i = 0; i < imgs.length; ++i) {
|
||||||
{img: 'Rucksack2.svg', linkable: ['Prekär']},
|
state.items.push({id: i, state: 'face-down', img: imgs[i]})
|
||||||
{img: 'Theater2.svg', linkable: ['Prekär']},
|
|
||||||
{img: 'UnskilledLabour2.svg', linkable: ['Prekär']},
|
|
||||||
{img: 'weben.svg', linkable: ['Prekär']}
|
|
||||||
]
|
|
||||||
for (let i = 0; i < items.length; ++i) {
|
|
||||||
state.items.push({id: i, state: 'face-down', img: items[i].img, linkable: items[i].linkable})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Actions {
|
class Actions {
|
||||||
|
|
@ -27,24 +21,21 @@ class Actions {
|
||||||
}
|
}
|
||||||
link(from, to) {
|
link(from, to) {
|
||||||
state.links.push({id: state.links.length, from, to})
|
state.links.push({id: state.links.length, from, to})
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const actions = new Actions
|
const actions = new Actions
|
||||||
|
|
||||||
let display
|
let display
|
||||||
const dispatch = target => {
|
const dispatch = target => {
|
||||||
let ret
|
|
||||||
if (target.action) {
|
if (target.action) {
|
||||||
ret = actions[target.action](target.from, target.to)
|
actions[target.action](target.from, target.to)
|
||||||
} else {
|
} else {
|
||||||
const match = target.match(/\/([^/]+)\/([^/]+)/)
|
const match = target.match(/\/([^/]+)\/([^/]+)/)
|
||||||
if (match && Object.hasOwnProperty.call(Actions.prototype, match[2])) {
|
if (match && Object.hasOwnProperty.call(Actions.prototype, match[2])) {
|
||||||
ret = actions[match[2]](match[1])
|
actions[match[2]](match[1])
|
||||||
} else actions.reset()
|
} else actions.reset()
|
||||||
}
|
}
|
||||||
display.render(state)
|
display.render(state)
|
||||||
return ret
|
|
||||||
}
|
}
|
||||||
window.onpopstate = e => {
|
window.onpopstate = e => {
|
||||||
dispatch(document.location.search)
|
dispatch(document.location.search)
|
||||||
|
|
|
||||||
64
style.css
64
style.css
|
|
@ -1,18 +1,6 @@
|
||||||
@font-face {
|
|
||||||
font-family: "Fell";
|
|
||||||
src: url("/IMFePIit29P.ttf");
|
|
||||||
}
|
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: "Fell Sc";
|
|
||||||
src: url("/IMFePIsc29P.ttf");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background-color: #e1eef2;
|
background-color: #e2eff3;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: "Fell";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.wrapper {
|
.wrapper {
|
||||||
|
|
@ -56,67 +44,23 @@ body {
|
||||||
background-position: center;
|
background-position: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.line {
|
|
||||||
border-bottom: 3px solid #1a1c1c;
|
|
||||||
height: 1em;
|
|
||||||
text-align: center;
|
|
||||||
position: absolute;
|
|
||||||
transform-origin: 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fullview {
|
.fullview {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
background-color: #e1eef280;
|
background-color: #858c8f90;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
.fullview > img {
|
.fullview > div {
|
||||||
|
background-color: #858c8f;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
min-width: 40em;
|
min-width: 40em;
|
||||||
min-height: 30em;
|
min-height: 30em;
|
||||||
max-height: 100%;
|
|
||||||
}
|
|
||||||
.fullview > div {
|
|
||||||
position: fixed;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
min-width: 20em;
|
|
||||||
min-height: 30em;
|
|
||||||
max-height: 100%;
|
|
||||||
background-color: #006680;
|
|
||||||
padding: 1.5em;
|
|
||||||
color: white;
|
|
||||||
border-radius: 20px;
|
|
||||||
border: 5px solid #1a1c1c;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
.fullview > div img {
|
|
||||||
float: right;
|
|
||||||
width: 120px;
|
|
||||||
border-radius: 80px;
|
|
||||||
border: 3px solid #1a1c1c;
|
|
||||||
margin-bottom: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1, .desc {
|
|
||||||
font-family: "Fell Sc";
|
|
||||||
}
|
|
||||||
|
|
||||||
.fulltext {
|
|
||||||
clear: both;
|
|
||||||
background-color: #99d7e9;
|
|
||||||
border-radius: 80px;
|
|
||||||
border: 3px solid #1a1c1c;
|
|
||||||
color: #1a1c1c;
|
|
||||||
margin-left: -10px;
|
|
||||||
padding: 0.5em;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue