Skip to content

Instantly share code, notes, and snippets.

@julkue
julkue / scroll-to-target.js
Created March 3, 2023 15:28
Scroll to target with configurable duration
// Source: https://htmldom.dev/scroll-to-an-element-smoothly/
const scrollToTarget = function (target, duration) {
const top = target.getBoundingClientRect().top;
const startPos = window.pageYOffset;
const diff = top;
let startTime = null;
let requestId;
const loop = function (currentTime) {
@julkue
julkue / README.txt
Last active January 11, 2022 18:39
Example of HTML import with Shadow DOM (isolated CSS)
1. Install e.g. http-server globally (https://www.npmjs.com/package/http-server)
2. Run http-server in this folder
3. Open http://localhost:8080/ in Chrome (there are polyfills available to make it work in other browsers too)
@julkue
julkue / magic360-restrictions.md
Last active January 2, 2023 13:25
Technical Restriction of the Magic 360 Plugin by Magic Toolbox
  1. The plugin is written in a "global" syntax, meaning that it depends on this references to window. Also it creates a global variable Magic360 using var Magic 360 = X. That means, that it doesn't work in CommonJS (e.g. Webpack) or AMD (e.g. RequireJS) environments. In case of Webpack it's necessary to use the script loader that runs it in the global context.
  2. The plugin doesn't allow a way to initialize new 360 viewers by JS. The only way it can work is by parsing elements with a class Magic360 on DOM ready. This means that you can't e.g. provide settings by JS for a single instance. You need to provide all options globally for all instances. Also, this means that if you're using AJAX you can't use this plugin, as the plugin doesn't re-parse the DOM after a XMLHttpRequest was done. Also, this means that you need to pass an instance "id" on every method call, which brings an incredible overhead (you would also create an id attribute on every
@julkue
julkue / why-to-host-github-project-websites-on-own-servers.md
Last active May 21, 2016 08:22
Why to host GitHub project websites on own servers?

Why to host GitHub project websites on own servers?

  1. When using GitHub pages to host a website this means that the website will be published over and over again for each fork (after a push). This is a problem for search engine optimization as it will be duplicate content. This is also a user experience problem, as users don't know which website is the original one.
  2. With GitHub pages it not possible to use htaccess. This is a problem for the following situations:
  • Calling a directory with "/" and with "/index.html" is possible (duplicate
@julkue
julkue / .htaccess
Last active July 28, 2021 15:17
Default .htaccess with configuration redirects to app.php
#/*!***************************************************
#* The MIT License (MIT)
#*
#* Copyright (c) 2014-2017, Julian Motz
#*
#* Permission is hereby granted, free of charge, to any person obtaining a copy
#* of this software and associated documentation files (the "Software"), to deal
#* in the Software without restriction, including without limitation the rights
#* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#* copies of the Software, and to permit persons to whom the Software is