我有相对复杂的公式,例如 transform: scale(var(--image-scale)) translateY(calc((1px * var(--element-height) * (var(--image-scale) - 1)) / 2 * var(--scrolled-out-y)))
如何调试计算值?此外,有没有一种方法可以验证/突出显示公式错误?
我试图这样输出到伪元素,但没有运气
position: fixed;
display: block;
left:0;
right: 0;
background: yellow;
padding: 5px;
z-index: 100;
content: calc((1px * var(--element-height) * (var(--image-scale) - 1)) / 2 * var(--scrolled-out-y));
Run Code Online (Sandbox Code Playgroud)
我发现的唯一方法是将计算的一部分放到未使用的数值属性background-position-x上,例如在下面的gif上,这样它将在计算选项卡上显示计算值-有用但不是很方便(background-position-x在页面滚动时注意更改):
position: fixed;
display: block;
left:0;
right: 0;
background: yellow;
padding: 5px;
z-index: 100;
content: calc((1px * var(--element-height) * (var(--image-scale) - 1)) / 2 * var(--scrolled-out-y));
Run Code Online (Sandbox Code Playgroud)
var sc = ScrollOut({
cssProps: true
})
const results …Run Code Online (Sandbox Code Playgroud)我创建别名c:\Users\user\.bash_profile和C:\Program Files\Git\etc\profile.d\aliases.sh,但都CONFIGS过得去VSCode综合终端,其配置为使用git bash的忽略:
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
Run Code Online (Sandbox Code Playgroud)
如果我打开GitBash本身 - 别名工作正常
如何强制集成终端尊重配置?
在 gif 上,您可以看到select()行为一致的输入(每次单击时选择的内容)和第二次输入,其中每 2 次单击都无法选择任何内容
我在项目中添加了历史上的全局样式
* {
user-select: none;
}
input {
user-select: text;
}
Run Code Online (Sandbox Code Playgroud)
我发现 -user-select: none在父级上设置的是select()其子级输入的破坏方法。
[ MDN ]
user-select: none: 元素及其子元素的文本是不可选择的。
我无法删除旧样式,因为它可能会影响太多东西(我们计划重新审视这个,但不是现在),所以我试图覆盖user-select行为,但在我设置时没有运气.parent {user-select: auto;} .parent .input {user-select: text;}
作为 JS 解决方法,我在此之前设置超时 200 毫秒select(),但闪烁难看。
如何正确覆盖这些 CSS 道具?(在这个例子中,我将损坏的输入包裹起来,.buggy以便另一个可以保持正常。但这并不代表项目结构,因为它在输入上方有几十个包装器,每个都有user-select: none)
刚刚发现这可以在chromium-based浏览器中重现- chrome/edge/opera
* {
user-select: none;
}
input {
user-select: text;
}
Run Code Online (Sandbox Code Playgroud)
.buggy * {
user-select: none;
}
.buggy input { …Run Code Online (Sandbox Code Playgroud)我看到一个奇怪的小间隙,在容器的边框和其中一个孩子的背景之间可以看到白色背景:
你会看到大概有 1px 的间隙。如何消除这个恼人的差距?
.login-modal {
background: white;
box-sizing: border-box;
--main-bg-color: rgb(70, 119, 139);
display: grid;
/* grid-auto-rows: minmax(20px, auto); */
grid-auto-columns: minmax(120px, 180px);
top: 10px;
position: absolute;
left: 50%;
transform: translate(-50%);
overflow: hidden;
border-radius: 7px;
color: var(--main-bg-color);
font-family: "Open Sans", sans-serif;
border: 1px solid var(--main-bg-color);
z-index: 1999;
}
#login-window-small.login-modal ul {
padding: 0;
margin: 0;
}
#login-window-small.login-modal li {
list-style-type: none;
margin: .5em;
}
#login-window-small.login-modal a {
text-decoration: none;
color: var(--main-bg-color);
}
.modal-head {
display: flex;
align-items: center;
color: …Run Code Online (Sandbox Code Playgroud)我正在构建指令,该指令应该在元素进入视口时添加类,并且还将触发自定义事件。我找到了 2 种触发事件的方法 -EventEmitter和dispatchEvent(),两者都可以正常工作。在这种情况下应该使用哪个,为什么?(对代码的任何其他建议表示赞赏)
import { EventEmitter, Directive, ElementRef, Renderer2, OnInit } from '@angular/core';
import { HostListener } from "@angular/core";
import { Component, Input, Output, Inject, PLATFORM_ID, ViewChild, ViewEncapsulation } from "@angular/core";
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
import { AfterViewInit } from '@angular/core/src/metadata/lifecycle_hooks';
@Directive({
selector: '[animateOnVisible]',
})
export class AnimateOnVisibleDirective implements AfterViewInit {
@Input() animateOnVisible: string = "fadeInUp";
@Output() enteredViewport: EventEmitter<string> = new EventEmitter();
public isBrowser: boolean;
private enableListener: boolean = true;
constructor(private renderer: …Run Code Online (Sandbox Code Playgroud)我发现transform财产取决于perspective()职位
为什么会发生这种情况?还有其他规则/限制吗transform?
虽然我觉得很奇怪,但这似乎不是一个错误,因为我可以在 Chrome/FF 中重现它
box:nth-child(1):hover {
transform: perspective(1000px) translate3d(0, 0, -100px);
}
box:nth-child(2):hover {
transform: translate3d(0, 0, 100px) perspective(1000px);
}
box {
padding: 20px;
display: inline-flex;
align-items: center;
justify-content: center;
font-family: monospace;
transition: transform .4s;
background: rgba(255, 0, 0, 0.3);
margin: 20px;
font-size: 12px;
perspective: 1000px;
cursor: pointer;
}
box:nth-child(2) {
background: rgba(0, 0, 255, 0.3);
}Run Code Online (Sandbox Code Playgroud)
<box>
transform: perspective(1000px) translate3d(0,0,100px);
</box>
<box>
transform: translate3d(0,0,100px) perspective(1000px);
</box>Run Code Online (Sandbox Code Playgroud)
我需要来自两个来源的数据组合成一个res: {data1: any, data2: any}对象,即使其中一个来源不发出任何值,我也需要实现这一目标
这是我期望的结构:
xxx (
source1,
source2,
(data1, data2) => ({data1: data1, data2: data2})
).subscribe(res => {
doSomething1(res.data1)
doSomething2(res.data2)
})
Run Code Online (Sandbox Code Playgroud)
有没有可以做到这一点的 rxjs 运营商?
目前我可以用的组合解决这个startWith和combineLatest-我发出空值,以便combineLatest可以开始发光值-没有更好的办法来解决这个不startWith(null)?
combineLatest (
source1.pipe(startWith(null)),
source2.pipe(startWith(null)),
(data1, data2) => ({data1: data1, data2: data2})
).subscribe(res => {
if(res.data1) {
doSomething1(res.data1)
}
if(res.data2) {
doSomething2(res.data2)
}
})
Run Code Online (Sandbox Code Playgroud) 我知道有各种用于自定义滚动的 JS 库,但我相信现代浏览器最好采用更一致和可预测的本机行为。我假设我将nice在 Chrome/Edge(Blink)acceptable中使用滚动条,在 FF 中使用它们自己简单的颜色/大小自定义,我不会关心其他浏览器。
我现在面临的唯一问题是 - 我希望li元素位于滚动条下方。我试图通过在其移动内容transform: translateX(15px)/ margin-right: -15px/ right: -15px/overflow: overlay并没有什么帮助(同时overflow:overlay做这项工作对于<body/>它不与内部容器的帮助)。
在没有 JS 的情况下实现所需行为的任何技巧?
*::-webkit-scrollbar-track {
background-color: transparent;
}
*::-webkit-scrollbar {
background-color: transparent;
transition: .3s;
}
*:hover::-webkit-scrollbar {
width: 15px !important;
}
*::-webkit-scrollbar-thumb {
border-radius: 10px;
border: 2px solid #444;
}
ul {
margin: 0;
padding: 0;
height: 100vh;
width: 70vw;
overflow-y: scroll;
background: linear-gradient(to top, #c6ffdd, #fbd786, …Run Code Online (Sandbox Code Playgroud)当我尝试使用从接收的blur()方法时,出现 TypeScript 错误:targetKeyboardEvent<HTMLInputElement>
类型“EventTarget”上不存在属性“blur”。ts(2339)
而相同的代码可以完美地target接收来自FocusEvent<HTMLInputElement>
这个的起源 -KeyboardEvent目标有EventTarget类型,而FocusEvent给出EventTarget & HTMLInputElement。
这是React.KeyboardEvent错误还是我如何在此处正确使用类型而不进行强制转换as?
StackBlitz上的 TS 问题演示
我的tscgitlab ci 工作失败了
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
我正在运行的脚本是
tsc -p test/tsconfig.json --noEmit
到目前为止我尝试过的是max-old-space-size通过以下方式增加:
cross-env NODE_OPTIONS=--max-old-space-size=8192 yarn print:heapsize && tsc -p test/tsconfig.json --noEmitcross-env NODE_OPTIONS='--max-old-space-size=8192' yarn print:heapsize && tsc -p test/tsconfig.json --noEmit(只是在 var 周围加上引号)node --max-old-space-size=8192 ./node_modules/.bin/tsc -p test/tsconfig.json --noEmit选项 #1 和 #2 不起作用,#3 工作正常,但对我来说运行二进制文件并将参数传递给node cli
所以我的问题是 - 我如何设置max-old-spce-sizeviatsc或者env variables也许还有另一种好方法来做到这一点?
yarn print:heapsize是我用来检查当前大小的脚本 - 它显示 #1 和 …
css ×5
angular ×2
html ×2
javascript ×2
typescript ×2
blink ×1
chromium ×1
css-calc ×1
eventemitter ×1
git-bash ×1
node.js ×1
reactjs ×1
rxjs ×1
rxjs6 ×1