当前位置: 首页 > 软件库 > 程序开发 > >

ember-basic-dropdown

The basic dropdown you ember app needs
授权协议 MIT License
开发语言 JavaScript
所属分类 程序开发
软件类型 开源软件
地区 不详
投 递 者 燕经国
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Ember-basic-dropdown

This is a very minimal dropdown. That means that it is agnostic about what it is going to contain.

It is intended to be a building block for more complex components but is perfectly usable. It isby example the addon on which ember-power-selector ember-paper's menu component are built upon.

Compatibility

Version 2.0 requires Ember 3.13 or greaterVersions 1.X require Ember 2.16 or greater

Installation

ember install ember-basic-dropdown

If you are using this addon in an application that uses ember-cli-sass, you need to import thestyles explicitly.

Add to your app.scss this line:

@import 'ember-basic-dropdown';

If you are using ember-power-select you don't needany of those steps because you already have this addon :D

Usage

This component leverages contextual components for its API:

<BasicDropdown as |dd|>
  <dd.Trigger>Click me</dd.Trigger>
  <dd.Content>Content of the trigger</dd.Content>
</BasicDropdown>

The yielded dropdown object is the public API of the component, and containsproperties and actions that you can use to control the component.

{
  uniqueId: <string>,
  isOpen: <boolean>,
  disabled: <boolean>,
  actions: {
    open: <action>,
    close: <action>,
    toggle: <action>,
    reposition: <action>
  }
}

Check the full documentation with live examples in http://ember-basic-dropdown.com

Features

Renders on the body or in place

By default this component will render the dropdown in the body using #-in-element and absolutelyposition it to place it in the proper coordinates.

You can opt out to this behavior by passing renderInPlace=true. That will add the dropdown justbelow the trigger.

Close automatically when clicking outside the component

You don't need to care about adding or removing events, it does that for you.

You can make the dropdown content standout a little more by adding overlay=true to the content options, see example below. This will add a semi transparent overlay covering the whole screen. Also this will stop bubbling the click/touch event which closed the dropdown.

<BasicDropdown as |dd|>
  <dd.Trigger>Click me!</dd.Trigger>
  <dd.Content @overlay={{true}}> {{!-- here! --}}
    content!
  </dd.Content>
</BasicDropdown>

NOTE: If for some reason clicking outside a dropdown doesn't work, you might want to make sure the <body> spans the entire viewport. Adding a css rule like body {min-height: 100vh;} would do the trick. It ensures that wherever you click on the page, it will close the dropdown.

Close automatically when clicking inside the component

If you'd like the dropdown to close itself after a user clicks on it, you can use dd.actions.close from our public API.

<BasicDropdown as |dd|>
  <dd.Trigger>Click me!</dd.Trigger>
  <dd.Content>
    <div {{action dd.actions.close}}>
      {{yield dd}}
    </div>
  </dd.Content>
</BasicDropdown>

Keyboard and touchscreen support

The trigger of the component is focusable by default, and when focused can be triggered using Enter or Space.It also listen to touch events so it works in mobile.

Easy to extend

The components provide hooks like onFocus, onBlur, onKeydown, onMouseEnter and more soyou can do pretty much anything you want.

Easy to animate.

You can animate it, in an out, with just CSS3 animations.Check the example in the Ember Power Select documentation

Intelligent and customizable positioning

This component is smart about where to position the dropdown. It will detect the best place to renderit based on the space around the trigger, and also will take care of reposition if if the screen isresized, scrolled, the device changes it orientation or the content of the dropdown changes.

You can force the component to be fixed in one position by passing verticalPosition = above | below and/or horizontalPosition = right | center | left.

If even that doesn't match your preferences and you feel brave enough, you can roll your own positioning logic if you pass a calculatePositionfunction. It's signature is:

calculatePosition(trigger, dropdown, { previousHorizontalPosition, horizontalPosition, previousVerticalPosition, verticalPosition, matchTriggerWidth })

The return value must be an object with this interface: { horizontalPosition, verticalPosition, style } wherewhere horizontalPosition is a string ("right" | "center" | "left"), verticalPosition is also a string("above" | "below") and style is an object with CSS properties, typically top and left/right.

Test helpers

It has a handy collection of test helpers to make interaction with the component seamless in yourtest suite.

Providing an Ember Twiddle

If you want to provide an Ember Twiddle with an issue/reproduction you need to add the following to the end of your template:<div id="ember-basic-dropdown-wormhole"></div>

Since Ember Twiddle does not run EmberCLI's hooks this div won't be added to the application and it's required (There's an issue in Ember Twiddle tracking this).

In order to create the Ember Twiddle you'll also need to add a reference to ember-basic-dropdown: version in the addons section of twiddle.json

  • public Dropdown drpd; void Start() { drpd.onValueChanged.AddListener(MyFunction); } void MyFunction(int index) { Debug.Log("------" + index); } 每当选择一个新的option时, onValueChanged会将被选择的option的索引传

  • <el-dropdown @command="handleCommand"> <!-- 绑定指令,在methods里定义--> <h1 class="el-dropdown-link exit"> {{username}}

 相关资料
  • Random.boolean( min?, max?, current? ) Random.boolean() Random.boolean( min, max, current ) 返回一个随机的布尔值。 min 可选。 指示参数 current 出现的概率。概率计算公式为 min / (min + max)。该参数的默认值为 1,即有 50% 的概率返回参数 current。 max 可选。

  • 描述 (Description) 标准菜单语法用于向下钻取菜单。 对于每个嵌套菜单,属性data-drilldown都包含在根《ul》和.menu中。 例子 (Example) 以下示例演示了在Foundation中使用向下钻取下拉菜单 - <!DOCTYPE html> <html> <head> <title>Foundation Template</title>

  • A simple implementation of the @handsontable/vue component.import Vue from 'vue'; import { HotTable } from '@handsontable/vue'; import Handsontable from 'handsontable'; new Vue({ el: '#example1', data

  • An implementation of the @handsontable/angular wrapper.// app.component.ts import { Component } from '@angular/core'; import * as Handsontable from 'handsontable'; @Component({ selector: 'app-root', t

  • An implementation of the @handsontable/react wrapper.import React from 'react'; import ReactDOM from 'react-dom'; import { HotTable } from '@handsontable/react'; import Handsontable from 'handsontable

  • Basicauth 中间件提供了Http Basic认证,是一个 Tango 的中间件。 安装 go get github.com/tango-contrib/basicauth 示例 type AuthAction struct {} func (a *AuthAction) Get() string { return "200" } func main() { tg := ta